Skip to content

Commit

Permalink
Merge pull request #243 from AuScope/master
Browse files Browse the repository at this point in the history
Merging master into dev-data
  • Loading branch information
stuartwoodman authored Jun 21, 2024
2 parents 9cd4cae + e927c77 commit 0a50684
Show file tree
Hide file tree
Showing 88 changed files with 22,014 additions and 418 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
- name: Set dynamic tag
id: set-tag
run: |
echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "COMMIT_SHA=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
if [[ "${{ github.ref }}" == "refs/heads/dev-sample" ]]; then
echo "::set-output name=tag::ghcr.io/auscope/auscope-ckan-dev:sample-latest"
elif [[ "${{ github.ref }}" == "refs/heads/dev-data" ]]; then
Expand All @@ -44,3 +46,9 @@ jobs:
file: ./ckan/Dockerfile # Consider using a separate Dockerfile for dev if needed
tags: ${{ steps.set-tag.outputs.tag }}
push: true
build-args: |
BRANCH_NAME=${{ env.BRANCH_NAME }}
COMMIT_SHA=${{ env.COMMIT_SHA }}
labels: |
branch=${{ env.BRANCH_NAME }}
commit_sha=${{ env.COMMIT_SHA }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ local/*
.vscode/
.env.dev
*kill*

.env.local

__pycache__/
18 changes: 13 additions & 5 deletions ckan/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
FROM ckan/ckan-base:2.10.1
#FROM ckan/ckan-base:2.9.9

ARG BRANCH_NAME
ARG COMMIT_SHA

LABEL branch="$BRANCH_NAME"
LABEL commit_sha="$COMMIT_SHA"


# Set up environment variables
ENV APP_DIR=/srv/app
ENV TZ=UTC
Expand Down Expand Up @@ -36,10 +43,6 @@ RUN if ! [ /usr/share/zoneinfo/${TZ} -ef /etc/localtime ]; then \
### Pages ###
#RUN pip3 install -e git+https://github.com/ckan/ckanext-pages.git#egg=ckanext-pages

### DCAT ###
#RUN pip3 install -e git+https://github.com/ckan/[email protected]#egg=ckanext-dcat && \
# pip3 install -r https://raw.githubusercontent.com/ckan/ckanext-dcat/v0.0.6/requirements.txt

### Spatial extension ###
RUN apk add python3-dev libxml2-dev libxslt-dev geos geos-dev proj proj-dev proj-util py3-shapely
RUN pip install --upgrade pip
Expand Down Expand Up @@ -71,6 +74,10 @@ RUN pip install -e "git+https://github.com/EnviDat/ckanext-composite.git#egg=cka
### Zip preview ###
RUN pip install -e "git+https://github.com/AuScope/ckanext-zippreview.git@master#egg=ckanext-zippreview"

### DCAT plugins ###
RUN pip install -r "https://raw.githubusercontent.com/ckan/ckanext-dcat/master/requirements.txt"
RUN pip install -e "git+https://github.com/AuScope/ckanext-dcat.git@auscope_customise#egg=ckanext-dcat"

# Clone the extension(s) your are writing for your own project in the `src` folder
# to get them mounted in this image at runtime

Expand Down Expand Up @@ -100,7 +107,8 @@ COPY src/shared/templates /shared/templates

RUN pip install $APP_DIR/src_extensions/ckanext-oidc-pkce && \
pip install $APP_DIR/src_extensions/ckanext-auscope-theme && \
pip install $APP_DIR/src_extensions/ckanext-igsn-theme
pip install $APP_DIR/src_extensions/ckanext-igsn-theme && \
pip install pandas openpyxl requests python-multipart

RUN chmod +x ${APP_DIR}/start_ckan.sh
# RUN chmod +x ${APP_DIR}/start_ckan_development.sh
Expand Down
13 changes: 7 additions & 6 deletions ckan/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ RUN if ! [ /usr/share/zoneinfo/${TZ} -ef /etc/localtime ]; then \
### Pages ###
#RUN pip3 install -e git+https://github.com/ckan/ckanext-pages.git#egg=ckanext-pages

### DCAT ###
#RUN pip3 install -e git+https://github.com/ckan/[email protected]#egg=ckanext-dcat && \
# pip3 install -r https://raw.githubusercontent.com/ckan/ckanext-dcat/v0.0.6/requirements.txt

### Spatial extension ###
RUN apk add python3-dev libxml2-dev libxslt-dev geos geos-dev proj proj-dev proj-util py3-shapely
RUN pip install --upgrade pip
Expand Down Expand Up @@ -73,6 +69,10 @@ RUN pip install -e "git+https://github.com/EnviDat/ckanext-composite.git#egg=cka
RUN pip install -e "git+https://github.com/AuScope/ckanext-zippreview.git@master#egg=ckanext-zippreview"


### DCAT plugins - used for exposing schema.org descriptions to search engines ###
RUN pip install -r "https://raw.githubusercontent.com/ckan/ckanext-dcat/master/requirements.txt"
RUN pip install -e "git+https://github.com/AuScope/ckanext-dcat.git@auscope_customise#egg=ckanext-dcat"

# Clone the extension(s) your are writing for your own project in the `src` folder
# to get them mounted in this image at runtime

Expand Down Expand Up @@ -101,7 +101,8 @@ COPY src/shared/templates /shared/templates
# RUN pip install $APP_DIR/src_extensions/ckanext-oidc-pkce

RUN pip install $APP_DIR/src_extensions/ckanext-oidc-pkce && \
pip install $APP_DIR/src_extensions/ckanext-auscope-theme && \
pip install $APP_DIR/src_extensions/ckanext-igsn-theme
pip install -e $APP_DIR/src_extensions/ckanext-auscope-theme && \
pip install -e $APP_DIR/src_extensions/ckanext-igsn-theme && \
pip install pandas openpyxl requests python-multipart

RUN chmod +x ${APP_DIR}/start_ckan_development.sh
2 changes: 1 addition & 1 deletion ckan/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[bumpversion]
current_version = 0.2.11
current_version = 0.2.13
commit = True
tag = True
55 changes: 50 additions & 5 deletions ckan/setup/start_ckan.sh.override
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

# Add ckan.datapusher.api_token to the CKAN config file (updated with corrected value later)
ckan config-tool $CKAN_INI ckan.datapusher.api_token=xxx
APP_DIR=$(dirname "$CKAN_INI")
SRC_EXTENSIONS_DIR=$APP_DIR/src_extensions
echo "Ckan app directory: $APP_DIR"

# Set up the Secret key used by Beaker and Flask
# This can be overriden using a CKAN___BEAKER__SESSION__SECRET env var
Expand All @@ -15,19 +18,61 @@ then
ckan config-tool $CKAN_INI "api_token.jwt.decode.secret=${JWT_SECRET}"
fi



### AUTH Settings ###
if [[ $plugins == *"igsn_theme"* ]]; then
if echo "$CKAN__PLUGINS" | grep -q "igsn_theme"; then
#ckan config-tool $CKAN_INI "ckan.auth.allow_dataset_collaborators = True"
ckan config-tool $CKAN_INI "ckan.auth.user_create_groups = True"
ckan config-tool $CKAN_INI "ckan.auth.user_create_groups = false"
#ckan config-tool $CKAN_INI "ckan.auth.create_unowned_dataset = True"
ckan config-tool $CKAN_INI "ckan.auth.user_create_organizations = True"
ckan config-tool $CKAN_INI "ckan.auth.user_create_organizations = false"
# ckan config-tool $CKAN_INI "ckan.dataset.create.require.resource = true"
ckan config-tool $CKAN_INI "ckan.dataset.create.require.resource = false"
# ckan config-tool $CKAN_INI "ckan.dataset.create_on_ui_requires_resources = true"
ckan config-tool $CKAN_INI "ckan.dataset.create_on_ui_requires_resources = false"

ckan config-tool $CKAN_INI "scheming.organization_schemas = ckanext.igsn_theme:sample_organization_schema.yaml"

export CKAN___SCHEMING__DATASET_SCHEMAS="ckanext.igsn_theme:sample_repository_schema.yaml"

ckan config-tool $CKAN_INI "ckan.locale_default = en_AU"
else
#ckan config-tool $CKAN_INI "ckan.auth.allow_dataset_collaborators = True"
ckan config-tool $CKAN_INI "ckan.auth.user_create_groups = False"
ckan config-tool $CKAN_INI "ckan.auth.user_create_groups = false"
#ckan config-tool $CKAN_INI "ckan.auth.create_unowned_dataset = True"
ckan config-tool $CKAN_INI "ckan.auth.user_create_organizations = False"
ckan config-tool $CKAN_INI "ckan.auth.user_create_organizations = false"

export CKAN___SCHEMING__DATASET_SCHEMAS="ckanext.auscope_theme:data_repository_schema.yaml"
fi

# Compiling translations for the custom extension
if echo "$CKAN__PLUGINS" | grep -q "igsn_theme"; then
echo "Compiling translations for custom CKAN extensions..."

for i in $SRC_EXTENSIONS_DIR/*; do
echo "Checking directory: $i"

# Adjust the path to where your i18n directory actually is
if [ -d "$i/ckanext/igsn_theme/i18n" ]; then
echo "Found i18n directory in $i/ckanext/igsn_theme/i18n"

# Navigate to each language directory and compile the .po files
for lang in "$i/ckanext/igsn_theme/i18n/"*; do
if [ -d "$lang" ]; then
echo "Compiling translations for language directory: $lang"
msgfmt "$lang/LC_MESSAGES/ckan.po" -o "$lang/LC_MESSAGES/ckan.mo"
echo "Compiled translations for $lang"
echo "Copying compiled lang to the src directory"
cp -r $SRC_EXTENSIONS_DIR/ckanext-igsn-theme/ckanext/igsn_theme/i18n/en_AU/LC_MESSAGES/* $APP_DIR/src/ckan/ckan/i18n/en_AU/LC_MESSAGES/
fi
done
else
echo "i18n directory not found in $i/ckanext/igsn_theme/i18n"
fi
done
fi


# This seems to be necessary as the envvar equivlents are not resolved
ckan config-tool $CKAN_INI "scheming.presets = ckanext.scheming:presets.json ckanext.repeating:presets.json ckanext.composite:presets.json"
ckan config-tool $CKAN_INI "scheming.dataset_schemas = $CKAN___SCHEMING__DATASET_SCHEMAS"
Expand Down
55 changes: 50 additions & 5 deletions ckan/setup/start_ckan_development.sh.override
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
echo "Looking for local extensions to install..."
echo "Extension dir contents:"
ls -la $SRC_EXTENSIONS_DIR

APP_DIR=$(dirname "$SRC_EXTENSIONS_DIR")
echo "Ckan app directory: $APP_DIR"

for i in $SRC_EXTENSIONS_DIR/*
do
if [ -d $i ];
Expand Down Expand Up @@ -73,17 +77,58 @@ ckan config-tool $SRC_DIR/ckan/test-core.ini \
"solr_url = $TEST_CKAN_SOLR_URL" \
"ckan.redis.url = $TEST_CKAN_REDIS_URL"


### AUTH Settings ###
if [[ $plugins == *"igsn_theme"* ]]; then
if echo "$CKAN__PLUGINS" | grep -q "igsn_theme"; then
#ckan config-tool $CKAN_INI "ckan.auth.allow_dataset_collaborators = True"
ckan config-tool $CKAN_INI "ckan.auth.user_create_groups = True"
ckan config-tool $CKAN_INI "ckan.auth.user_create_groups = false"
#ckan config-tool $CKAN_INI "ckan.auth.create_unowned_dataset = True"
ckan config-tool $CKAN_INI "ckan.auth.user_create_organizations = True"
ckan config-tool $CKAN_INI "ckan.auth.user_create_organizations = false"
# ckan config-tool $CKAN_INI "ckan.dataset.create.require.resource = true"
ckan config-tool $CKAN_INI "ckan.dataset.create.require.resource = false"
# ckan config-tool $CKAN_INI "ckan.dataset.create_on_ui_requires_resources = true"
ckan config-tool $CKAN_INI "ckan.dataset.create_on_ui_requires_resources = false"

ckan config-tool $CKAN_INI "scheming.organization_schemas = ckanext.igsn_theme:sample_organization_schema.yaml"

export CKAN___SCHEMING__DATASET_SCHEMAS="ckanext.igsn_theme:sample_repository_schema.yaml"


ckan config-tool $CKAN_INI "ckan.locale_default = en_AU"
else
#ckan config-tool $CKAN_INI "ckan.auth.allow_dataset_collaborators = True"
ckan config-tool $CKAN_INI "ckan.auth.user_create_groups = False"
ckan config-tool $CKAN_INI "ckan.auth.user_create_groups = false"
#ckan config-tool $CKAN_INI "ckan.auth.create_unowned_dataset = True"
ckan config-tool $CKAN_INI "ckan.auth.user_create_organizations = False"
ckan config-tool $CKAN_INI "ckan.auth.user_create_organizations = false"

export CKAN___SCHEMING__DATASET_SCHEMAS="ckanext.auscope_theme:data_repository_schema.yaml"
fi

# Compiling translations for the custom extension
if echo "$CKAN__PLUGINS" | grep -q "igsn_theme"; then
echo "Compiling translations for custom CKAN extensions..."

for i in $SRC_EXTENSIONS_DIR/*; do
echo "Checking directory: $i"

# Adjust the path to where your i18n directory actually is
if [ -d "$i/ckanext/igsn_theme/i18n" ]; then
echo "Found i18n directory in $i/ckanext/igsn_theme/i18n"

# Navigate to each language directory and compile the .po files
for lang in "$i/ckanext/igsn_theme/i18n/"*; do
if [ -d "$lang" ]; then
echo "Compiling translations for language directory: $lang"
msgfmt "$lang/LC_MESSAGES/ckan.po" -o "$lang/LC_MESSAGES/ckan.mo"
echo "Compiled translations for $lang"
echo "Copying compiled lang to the src directory"
cp -r $SRC_EXTENSIONS_DIR/ckanext-igsn-theme/ckanext/igsn_theme/i18n/en_AU/LC_MESSAGES/* $APP_DIR/src/ckan/ckan/i18n/en_AU/LC_MESSAGES/
fi
done
else
echo "i18n directory not found in $i/ckanext/igsn_theme/i18n"
fi
done
fi

### Scheming Settings ###
Expand Down
14 changes: 12 additions & 2 deletions ckan/src/ckanext-auscope-theme/ckanext/auscope_theme/logic/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,26 @@ def resource_view_delete(next_auth, context, data_dict):


@tk.chained_auth_function
@tk.auth_allow_anonymous_access
def package_show(next_auth, context, data_dict):
user = context.get('auth_user_obj')
package = get_package_object(context, data_dict)

# All public packages available to everyone
if package and not package.private:
return {'success': True}

user = context.get('auth_user_obj')
# No access to anonymous user for a private package
if user is None:
return {'success': False}

# Admins, editors and collaborators should be able to access private packages
if package and package.owner_org:
user_role = authz.users_role_for_group_or_org(package.owner_org, user.name)
if (user_role != 'admin' and user_role != 'editor') and package.private and hasattr(user, 'id') and package.creator_user_id != user.id \
and not authz.user_is_collaborator_on_dataset(user.id, package.id):
return {'success': False, 'msg': 'This dataset is private.'}

return next_auth(context, data_dict)


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% ckan_extends %}

{% block facet_list %}
{% set hide_empty = hide_empty or false %}
{% with items = items or h.get_facet_items_dict(name, search_facets) %}
{% if items or not hide_empty %}
{% if name not in ['organization', 'groups' , 'license_id'] %}
{% block facet_list_item %}
<section class="module module-narrow module-shallow">
{% block facet_list_heading %}
<h2 class="module-heading">
<i class="fa fa-filter"></i>
{% if name == 'tags' %}
Keywords
{% else %}
{{ title }}
{% endif %}
</h2>
{% endblock %}

{% block facet_list_items %}
{{ super() }}
{% endblock %}

</section>
{% endblock %}
{% endif %}
{% endif %}
{% endwith %}
{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,8 +1,48 @@
/*
NOTE:
The following styles are for testing purposes only.
Please insert the actual CSS styles for the igsn-theme extension below this comment block.
*/
.media-overlay .media-heading {
background-color: #282572;
}

.stages {
margin: 0;
list-style: none;
color: #aeaeae;
counter-reset: none;
overflow: hidden;
margin-bottom: 1.5rem;
padding: 0;
}

.stages::after {
display: block;
clear: both;
content: "";
}

.stages li::before {
display: block;
clear: both;
content: "";

}
.stages li {
line-height: 27px;
counter-increment: none;
width: 100%;
background-color: transparent;
float: left;
padding: 10px 20px;
position: relative;
z-index: 0;
}

.badge {
display: inline-block;
padding: 0.25em 0.6em;
font-size: 75%;
font-weight: 700;
line-height: 1;
text-align: center;
white-space: nowrap;
vertical-align: baseline;
border-radius: 0.375rem;
background-color: #2e2b8a; /* Primary blue */
color: white; /* Text color */
margin-right: 5px; /* Space between badges */
}
Loading

0 comments on commit 0a50684

Please sign in to comment.