forked from City-of-Helsinki/kerrokantasi
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from City-of-Turku/develop
Release tku-v1.10
- Loading branch information
Showing
20 changed files
with
439 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Kerrokantasi tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- release | ||
- develop | ||
pull_request: | ||
branches: | ||
- '**' | ||
|
||
jobs: | ||
build: | ||
runs-on: [ ubuntu-20.04 ] | ||
services: | ||
postgres: | ||
image: postgis/postgis:11-2.5 | ||
env: | ||
POSTGRES_USER: kerrokantasi | ||
POSTGRES_PASSWORD: kerrokantasi | ||
POSTGRES_DB: kerrokantasi | ||
SECRET_KEY: kerrokantasi_secret | ||
DEBUG: true | ||
POSTGRES_HOST_AUTH_METHOD: trust | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
- 5432:5432 | ||
strategy: | ||
matrix: | ||
python-version: ["3.7", "3.8", "3.9"] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install Ubuntu packages | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install gettext python-dev libpq-dev gdal-bin -y | ||
- name: Install requirements | ||
run: | | ||
python3 -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
pip install -r requirements-dev.txt | ||
- name: Apply migrations | ||
env: | ||
DATABASE_URL: postgis://kerrokantasi:kerrokantasi@localhost/kerrokantasi | ||
DEBUG: true | ||
SECRET_KEY: kerrokantasi_secret | ||
run: | | ||
python3 manage.py migrate | ||
- name: Compile translations | ||
env: | ||
DATABASE_URL: postgis://kerrokantasi:kerrokantasi@localhost/kerrokantasi | ||
DEBUG: true | ||
SECRET_KEY: kerrokantasi_secret | ||
run: | | ||
python3 manage.py compilemessages | ||
- name: Run tests | ||
env: | ||
DATABASE_URL: postgis://kerrokantasi:kerrokantasi@localhost/kerrokantasi | ||
DEBUG: true | ||
SECRET_KEY: kerrokantasi_secret | ||
HEARING_REPORT_PUBLIC_AUTHOR_NAMES: false | ||
GITHUB_ACTION_TEST: 'true' | ||
run: | | ||
pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Generated by Django 2.2.28 on 2022-08-31 09:01 | ||
|
||
from django.conf import settings | ||
import django.core.files.storage | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django.utils.timezone | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('democracy', '0058_poll_answer_cascade'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='OrganizationLog', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('action', models.TextField(verbose_name='Action')), | ||
('created_at', models.DateTimeField(db_index=True, default=django.utils.timezone.now, editable=False, verbose_name='time of creation')), | ||
('action_by', models.ForeignKey(blank=True, editable=False, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='organizationlog_action_by', to=settings.AUTH_USER_MODEL, verbose_name='action by')), | ||
('organization', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='organization_log', to='democracy.Organization', verbose_name='organization')), | ||
], | ||
options={ | ||
'verbose_name': 'organization log', | ||
'verbose_name_plural': 'organization logs', | ||
}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from django.db.models.signals import m2m_changed | ||
from democracy.models.organization import Organization, OrganizationLog | ||
from kerrokantasi.models import User | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
|
||
|
||
def organization_log_signal(sender, **kwargs): | ||
instance = kwargs.get('instance', None) | ||
action = kwargs.get('action') | ||
pk_set = kwargs.get('pk_set') | ||
if any(isinstance(_id, str) for _id in pk_set): | ||
return | ||
users = User.objects.filter(pk__in=pk_set) | ||
if action == 'post_add': | ||
OrganizationLog.objects.create( | ||
organization=instance, | ||
action=_('Added: %(email)s') % ({ 'email': ', '.join([user.email for user in users]) }), | ||
action_by=instance.modified_by | ||
) | ||
elif action == 'post_remove': | ||
OrganizationLog.objects.create( | ||
organization=instance, | ||
action=_('Removed: %(email)s') % ({ 'email': ', '.join([user.email for user in users]) }), | ||
action_by=instance.modified_by | ||
) | ||
|
||
m2m_changed.connect(organization_log_signal, sender=Organization.admin_users.through) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.