Skip to content

Commit

Permalink
Merge branch 'main' into 720-new-member-mail
Browse files Browse the repository at this point in the history
  • Loading branch information
supertom01 authored Feb 3, 2025
2 parents 64a9d81 + cf0fe1a commit f810d97
Show file tree
Hide file tree
Showing 176 changed files with 14,273 additions and 12,068 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/build_docker_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Build docker image and run tests

on: [push, pull_request]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

services:
mariadb:
image: mariadb:10.4
env:
MARIADB_USER: amelie_test
MARIADB_PASSWORD: amelie_test
MYSQL_DATABASE: amelie_test
MYSQL_ROOT_PASSWORD: amelie_test
ports: ['3306:3306']
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
id: push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Verify MariaDB connection
run: |
while ! mysqladmin ping -h"127.0.0.1" -P"3306" --silent; do
sleep 1
done
- name: Run Amelie tests
run: |
docker run --rm --entrypoint "/amelie/scripts/run_tests.sh" ghcr.io/inter-actief/amelie@${{ steps.push.outputs.digest }}
- name: Cleanup untagged images older than 1 week
uses: snok/container-retention-policy@v2
with:
image-names: amelie
cut-off: 1 week ago UTC
account-type: org
org-name: Inter-Actief
token: ${{ secrets.GITHUB_TOKEN }}
token-type: github-token
untagged-only: true

- name: Cleanup tagged images (except main, production and graphql) older than 1 month
uses: snok/container-retention-policy@v2
with:
image-names: amelie
cut-off: 1 month ago UTC
account-type: org
org-name: Inter-Actief
token: ${{ secrets.GITHUB_TOKEN }}
token-type: github-token
skip-tags: main, production, 741-graphql-api
13 changes: 0 additions & 13 deletions .github/workflows/ia_gitlab_ci.yml

This file was deleted.

32 changes: 0 additions & 32 deletions .github/workflows/ia_gitlab_ci_retrieve.yml

This file was deleted.

42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Build the amelie docker image based on Debian 11 (Bullseye)
FROM debian:bullseye

# Copy amelie sources
COPY . /amelie

# Set /amelie as startup working directory
WORKDIR /amelie

# Install required packages for amelie and prepare the system to run Amelie
RUN echo "Updating repostitories..." && \
apt-get update -y && \
echo "Upgrading base debian system..." && \
apt-get upgrade -y && \
echo "Installing Amelie required packages..." && \
apt-get install -y apt-utils git net-tools python3 python3-pip mariadb-client libmariadb-dev xmlsec1 libssl-dev libldap-dev libsasl2-dev libjpeg-dev zlib1g-dev gettext locales acl && \
echo "Enabling 'nl_NL' and 'en_US' locales..." && \
sed -i -e 's/# nl_NL.UTF-8 UTF-8/nl_NL.UTF-8 UTF-8/' /etc/locale.gen && \
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
echo "Rebuilding locales..." && \
dpkg-reconfigure --frontend=noninteractive locales && \
echo "Creating directories for amelie..." && \
mkdir -p /amelie /config /static /media /photo_upload /data_exports /homedir_exports /var/log /var/run && \
echo "Installing python requirements..." && \
pip3 install -r requirements.txt && \
echo "Correcting permissions on directories..." && \
chown -R 1000:1000 /amelie /config /static /media /photo_upload /data_exports /homedir_exports /var/log

# Switch back to a local user
USER 1000:1000

# Check if Django can run
RUN python3 manage.py check

# Expose volumes
VOLUME ["/config", "/static", "/media", "/photo_upload", "/data_exports", "/homedir_exports"]

# Expose the web port
EXPOSE 8000

# Start the website
CMD ["/amelie/scripts/start_web_asgi.sh"]
16 changes: 8 additions & 8 deletions amelie/about/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
from django.db import models
from django.template.defaultfilters import slugify
from django.utils.translation import get_language
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext_lazy as _l


class Page(models.Model):
name_nl = models.CharField(max_length=100, verbose_name=_('Name'))
name_en = models.CharField(max_length=100, verbose_name=_('Name (en)'), blank=True)
name_nl = models.CharField(max_length=100, verbose_name=_l('Name'))
name_en = models.CharField(max_length=100, verbose_name=_l('Name (en)'), blank=True)
slug_nl = models.SlugField(max_length=100, editable=False)
slug_en = models.SlugField(max_length=100, editable=False)
educational = models.BooleanField(default=False, verbose_name=_("Educational page?"))
content_nl = models.TextField(verbose_name=_('Content'))
content_en = models.TextField(verbose_name=_('Content (en)'), blank=True)
educational = models.BooleanField(default=False, verbose_name=_l("Educational page?"))
content_nl = models.TextField(verbose_name=_l('Content'))
content_en = models.TextField(verbose_name=_l('Content (en)'), blank=True)
last_modified = models.DateTimeField(auto_now=True)

class Meta:
ordering = ['name_nl']
verbose_name = _('Page')
verbose_name_plural = _("Pages")
verbose_name = _l('Page')
verbose_name_plural = _l("Pages")

def __str__(self):
return self.name
Expand Down
25 changes: 10 additions & 15 deletions amelie/about/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,17 @@ def get_redirect_url(self, *args, **kwargs):

def page(request, pk, slug):
obj = get_object_or_404(Page, pk=pk)
is_www = (hasattr(request, 'is_board') and request.is_board) or \
(hasattr(request, 'person') and request.person.function_set.filter(committee__abbreviation='WWW',
end__isnull=True))
is_educational = hasattr(request, 'person') and request.person.function_set.filter(committee__abbreviation='OnderwijsCommissie',
end__isnull=True)
is_www = hasattr(request, 'person') and (request.person.is_board() or request.person.is_in_committee('WWW'))
is_educational = hasattr(request, 'person') and (request.person.is_board() or request.person.is_in_committee('OnderwijsCommissie'))
return render(request, 'page.html', {'obj': obj, 'is_www': is_www, 'is_educational': is_educational})


def page_edit(request, pk, slug):
obj = get_object_or_404(Page, pk=pk)
if hasattr(request, 'person') and (
request.person.is_board() or request.person.function_set.filter(committee__abbreviation='WWW',
end__isnull=True).exists() or (
obj.educational and request.person.function_set.filter(committee__abbreviation='OnderwijsCommissie',
end__isnull=True).exists())):
is_board = hasattr(request, 'person') and request.person.is_board()
is_www = hasattr(request, 'person') and request.person.is_in_committee('WWW')
is_educational = hasattr(request, 'person') and request.person.is_in_committee('OnderwijsCommissie')
if is_board or is_www or (obj.educational and is_educational):
form = PageForm(instance=obj) if request.method != "POST" else PageForm(request.POST, instance=obj)
is_new = False

Expand All @@ -50,11 +46,10 @@ def page_edit(request, pk, slug):

def page_delete(request, pk, slug):
obj = get_object_or_404(Page, pk=pk)
if hasattr(request, 'person') and (
request.person.is_board() or request.person.function_set.filter(committee__abbreviation='WWW',
end__isnull=True).exists() or (
obj.educational and request.person.function_set.filter(committee__abbreviation='OnderwijsCommissie',
end__isnull=True).exists())):
is_board = hasattr(request, 'person') and request.person.is_board()
is_www = hasattr(request, 'person') and request.person.is_in_committee('WWW')
is_educational = hasattr(request, 'person') and request.person.is_in_committee('OnderwijsCommissie')
if is_board or is_www or (obj.educational and is_educational):
if request.method == "POST":
obj.delete()
return HttpResponseRedirect("/")
Expand Down
6 changes: 3 additions & 3 deletions amelie/activities/feeds.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from django.contrib.syndication.views import Feed
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext_lazy as _l

from amelie.activities.models import Activity


class Activities(Feed):
link = '/activities/'
title = _('IA Events')
description = _('Inter-Actief\'s activities in the coming weeks')
title = _l('IA Events')
description = _l('Inter-Actief\'s activities in the coming weeks')

title_template = "feeds/news_title.html"
description_template = "feeds/news_content.html"
Expand Down
Loading

0 comments on commit f810d97

Please sign in to comment.