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 #15 from City-of-Turku/release-candidate
Release candidate
- Loading branch information
Showing
26 changed files
with
688 additions
and
141 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 |
---|---|---|
|
@@ -48,3 +48,6 @@ var/ | |
migrator/*.json | ||
migrator/*.xml | ||
config_dev.toml | ||
protected_media/ | ||
media/ | ||
.vscode |
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,19 @@ | ||
# Generated by Django 2.2.10 on 2020-02-25 13:49 | ||
|
||
import django.core.files.storage | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('democracy', '0050_add_on_deletes'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='sectionfile', | ||
name='file', | ||
field=models.FileField(max_length=2048, storage=django.core.files.storage.FileSystemStorage(location='/home/santtua/kerrokantasi/protected_media'), upload_to='files/%Y/%m', verbose_name='file'), | ||
), | ||
] |
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,36 @@ | ||
# Generated by Django 2.2.10 on 2020-04-01 11:15 | ||
|
||
import democracy.enums | ||
import django.core.files.storage | ||
from django.db import migrations, models | ||
import enumfields.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('democracy', '0051_auto_20200225_1349'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='section', | ||
name='commenting_map_tools', | ||
field=enumfields.fields.EnumIntegerField(default=0, enum=democracy.enums.CommentingMapTools, verbose_name='commenting_map_tools'), | ||
), | ||
migrations.AddField( | ||
model_name='sectioncomment', | ||
name='commenting_map_tools', | ||
field=enumfields.fields.EnumIntegerField(default=0, enum=democracy.enums.CommentingMapTools, verbose_name='commenting_map_tools'), | ||
), | ||
migrations.AddField( | ||
model_name='sectioncomment', | ||
name='map_comment_text', | ||
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='map_comment_text'), | ||
), | ||
migrations.AlterField( | ||
model_name='sectionfile', | ||
name='file', | ||
field=models.FileField(max_length=2048, storage=django.core.files.storage.FileSystemStorage(location='/home/hienous/kerrokantasi/protected_media'), upload_to='files/%Y/%m', verbose_name='file'), | ||
), | ||
] |
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,71 @@ | ||
# Generated by Django 2.2.12 on 2020-08-13 11:12 | ||
|
||
import django.core.files.storage | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import parler.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('democracy', '0052_auto_20200401_1115'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='contactpersontranslation', | ||
name='master', | ||
field=parler.fields.TranslationsForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='translations', to='democracy.ContactPerson'), | ||
), | ||
migrations.AlterField( | ||
model_name='hearingtranslation', | ||
name='master', | ||
field=parler.fields.TranslationsForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='translations', to='democracy.Hearing'), | ||
), | ||
migrations.AlterField( | ||
model_name='labeltranslation', | ||
name='master', | ||
field=parler.fields.TranslationsForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='translations', to='democracy.Label'), | ||
), | ||
migrations.AlterField( | ||
model_name='projectphasetranslation', | ||
name='master', | ||
field=parler.fields.TranslationsForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='translations', to='democracy.ProjectPhase'), | ||
), | ||
migrations.AlterField( | ||
model_name='projecttranslation', | ||
name='master', | ||
field=parler.fields.TranslationsForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='translations', to='democracy.Project'), | ||
), | ||
migrations.AlterField( | ||
model_name='sectionfile', | ||
name='file', | ||
field=models.FileField(max_length=2048, storage=django.core.files.storage.FileSystemStorage(location='/srv/kerrokantasi/user_uploads'), upload_to='files/%Y/%m', verbose_name='file'), | ||
), | ||
migrations.AlterField( | ||
model_name='sectionfiletranslation', | ||
name='master', | ||
field=parler.fields.TranslationsForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='translations', to='democracy.SectionFile'), | ||
), | ||
migrations.AlterField( | ||
model_name='sectionimagetranslation', | ||
name='master', | ||
field=parler.fields.TranslationsForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='translations', to='democracy.SectionImage'), | ||
), | ||
migrations.AlterField( | ||
model_name='sectionpolloptiontranslation', | ||
name='master', | ||
field=parler.fields.TranslationsForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='translations', to='democracy.SectionPollOption'), | ||
), | ||
migrations.AlterField( | ||
model_name='sectionpolltranslation', | ||
name='master', | ||
field=parler.fields.TranslationsForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='translations', to='democracy.SectionPoll'), | ||
), | ||
migrations.AlterField( | ||
model_name='sectiontranslation', | ||
name='master', | ||
field=parler.fields.TranslationsForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='translations', to='democracy.Section'), | ||
), | ||
] |
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
from django.utils.timezone import now | ||
from rest_framework.test import APIClient | ||
|
||
from democracy.enums import Commenting, InitialSectionType | ||
from democracy.enums import Commenting, InitialSectionType, CommentingMapTools | ||
from democracy.factories.hearing import HearingFactory, LabelFactory | ||
from democracy.models import ContactPerson, Hearing, Label, Project, ProjectPhase, Section, SectionFile, SectionType, Organization | ||
from democracy.tests.utils import FILES, assert_ascending_sequence, create_default_images, create_default_files, get_file_path | ||
|
@@ -70,6 +70,7 @@ def default_hearing(john_doe, contact_person, default_organization, default_proj | |
Fixture for a "default" hearing with three sections (one main, two other sections). | ||
All objects will have the 3 default images attached. | ||
All objects will allow open commenting. | ||
All objects will have commenting_map_tools all | ||
""" | ||
hearing = Hearing.objects.create( | ||
title='Default test hearing One', | ||
|
@@ -85,7 +86,8 @@ def default_hearing(john_doe, contact_person, default_organization, default_proj | |
abstract='Section %d abstract' % x, | ||
hearing=hearing, | ||
type=SectionType.objects.get(identifier=section_type), | ||
commenting=Commenting.OPEN | ||
commenting=Commenting.OPEN, | ||
commenting_map_tools=CommentingMapTools.ALL | ||
) | ||
create_default_images(section) | ||
create_default_files(section) | ||
|
@@ -100,6 +102,35 @@ def default_hearing(john_doe, contact_person, default_organization, default_proj | |
return hearing | ||
|
||
|
||
@pytest.fixture() | ||
def strong_auth_hearing(john_doe, contact_person, default_organization, default_project): | ||
""" | ||
Fixture for a "strong auth requiring" hearing with one main section. | ||
Commenting requires strong auth. | ||
""" | ||
hearing = Hearing.objects.create( | ||
title='Strong auth test hearing', | ||
open_at=now() - datetime.timedelta(days=1), | ||
close_at=now() + datetime.timedelta(days=1), | ||
slug='strong-auth-hearing-slug', | ||
organization=default_organization, | ||
project_phase=default_project.phases.all()[0], | ||
) | ||
|
||
section_type = InitialSectionType.MAIN | ||
Section.objects.create( | ||
abstract='Section abstract for strong auth', | ||
hearing=hearing, | ||
type=SectionType.objects.get(identifier=section_type), | ||
commenting=Commenting.STRONG | ||
) | ||
|
||
assert_ascending_sequence([s.ordering for s in hearing.sections.all()]) | ||
hearing.contact_persons.add(contact_person) | ||
|
||
return hearing | ||
|
||
|
||
@pytest.fixture() | ||
def default_project(): | ||
project_data = { | ||
|
@@ -179,6 +210,28 @@ def jane_doe_api_client(jane_doe): | |
api_client.user = jane_doe | ||
return api_client | ||
|
||
@pytest.fixture() | ||
def stark_doe(): | ||
""" | ||
Stark Doe is another average registered user. | ||
""" | ||
user = get_user_model().objects.filter(username="stark_doe").first() | ||
if not user: # pragma: no branch | ||
user = get_user_model().objects.create_user("stark_doe", "[email protected]", password="password") | ||
return user | ||
|
||
|
||
@pytest.fixture() | ||
def stark_doe_api_client(stark_doe): | ||
""" | ||
Stark Doe is another average registered user; this is his API client. | ||
Stark uses strong authentication. | ||
""" | ||
api_client = APIClient() | ||
api_client.force_authenticate(user=stark_doe) | ||
api_client.user = stark_doe | ||
api_client.user.has_strong_auth = True | ||
return api_client | ||
|
||
@pytest.fixture() | ||
def john_smith(default_organization): | ||
|
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
Oops, something went wrong.