Skip to content

Commit

Permalink
Merge pull request #150 from manuGil/devel
Browse files Browse the repository at this point in the history
February's sprint
  • Loading branch information
manuGil authored Mar 1, 2024
2 parents 1634413 + 174f58e commit 781d581
Show file tree
Hide file tree
Showing 25 changed files with 503 additions and 7,192 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,7 @@ dmypy.json
*.iws

# OS
.DS_Store
.DS_Store

# devel
dev-notes.md
74 changes: 41 additions & 33 deletions citizenvoice/apiapp/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Generated by Django 4.1.12 on 2023-11-08 09:39
# Generated by Django 5.0 on 2024-02-29 23:12

import apiapp.models.mapview
from django.conf import settings
import django.contrib.gis.db.models.fields
from django.db import migrations, models
import django.db.models.deletion
import uuid
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
Expand All @@ -20,8 +21,8 @@ class Migration(migrations.Migration):
name='Answer',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created', models.DateTimeField(verbose_name='Creation date')),
('updated', models.DateTimeField(verbose_name='Last edited')),
('created', models.DateTimeField(auto_now_add=True, verbose_name='Creation date')),
('updated', models.DateTimeField(auto_now=True, verbose_name='Last edited')),
('body', models.TextField(verbose_name='Answer Body')),
],
),
Expand All @@ -32,33 +33,7 @@ class Migration(migrations.Migration):
('name', models.CharField(default='Delft', max_length=150, verbose_name='Name of the MapView location')),
('map_service_url', models.CharField(default=apiapp.models.mapview.default_service_url, max_length=150, verbose_name='Map Service URL')),
('options', models.JSONField(default=apiapp.models.mapview.default_options, verbose_name='Map service specific options')),
('geometries', models.JSONField(null=True, verbose_name='Custom geometries for the map view')),
],
),
migrations.CreateModel(
name='Survey',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=150, verbose_name='Name of the survey')),
('description', models.TextField(blank=True, verbose_name='Description')),
('is_published', models.BooleanField(default=False, verbose_name='Survey is visible and accessible to users')),
('need_logged_user', models.BooleanField(default=False, verbose_name='Only authenticated users have access to this survey')),
('editable_answers', models.BooleanField(default=True, verbose_name='Answers can be edited after submission')),
('publish_date', models.DateTimeField(verbose_name='Date that survey was made available')),
('expire_date', models.DateTimeField(verbose_name='Expiry date of survey')),
('public_url', models.CharField(default='', max_length=255, verbose_name='Public URL')),
('designer', models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Response',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created', models.DateTimeField(auto_now_add=True, verbose_name='Date response was submitted')),
('updated', models.DateTimeField(auto_now=True, verbose_name='Last edit')),
('interview_uuid', models.CharField(max_length=150, verbose_name='Unique ID of interview')),
('respondent', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
('survey', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='apiapp.survey')),
('geometries', models.JSONField(blank=True, null=True, verbose_name='Custom geometries for the map view')),
],
),
migrations.CreateModel(
Expand All @@ -72,7 +47,6 @@ class Migration(migrations.Migration):
('choices', models.TextField(blank=True, null=True, verbose_name='Choices for answers')),
('is_geospatial', models.BooleanField(default=False, verbose_name='If the question must be answered geospatially or not')),
('map_view', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='apiapp.mapview')),
('survey', models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='apiapp.survey')),
],
options={
'verbose_name': 'question',
Expand Down Expand Up @@ -124,9 +98,43 @@ class Migration(migrations.Migration):
name='question',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='apiapp.question'),
),
migrations.CreateModel(
name='Response',
fields=[
('created', models.DateTimeField(auto_now_add=True, verbose_name='Date response was submitted')),
('updated', models.DateTimeField(auto_now=True, verbose_name='Last edit')),
('interview_uuid', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False, unique=True, verbose_name='Unique ID of interview')),
('respondent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.AddField(
model_name='answer',
name='response',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='apiapp.response'),
),
migrations.CreateModel(
name='Survey',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=150, verbose_name='Name of the survey')),
('description', models.TextField(blank=True, verbose_name='Description')),
('is_published', models.BooleanField(default=False, verbose_name='Survey is visible and accessible to users')),
('need_logged_user', models.BooleanField(default=False, verbose_name='Only authenticated users have access to this survey')),
('editable_answers', models.BooleanField(default=True, verbose_name='Answers can be edited after submission')),
('publish_date', models.DateTimeField(verbose_name='Date that survey was made available')),
('expire_date', models.DateTimeField(verbose_name='Expiry date of survey')),
('public_url', models.CharField(blank=True, max_length=255, verbose_name='Public URL')),
('designer', models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.AddField(
model_name='response',
name='survey',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='apiapp.survey'),
),
migrations.AddField(
model_name='question',
name='survey',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='apiapp.survey'),
),
]
21 changes: 0 additions & 21 deletions citizenvoice/apiapp/migrations/0002_alter_response_respondent.py

This file was deleted.

18 changes: 0 additions & 18 deletions citizenvoice/apiapp/migrations/0003_alter_mapview_geometries.py

This file was deleted.

This file was deleted.

This file was deleted.

20 changes: 0 additions & 20 deletions citizenvoice/apiapp/migrations/0006_answer_response.py

This file was deleted.

19 changes: 0 additions & 19 deletions citizenvoice/apiapp/migrations/0007_alter_answer_response.py

This file was deleted.

19 changes: 0 additions & 19 deletions citizenvoice/apiapp/migrations/0008_alter_answer_response.py

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion citizenvoice/apiapp/models/survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Survey(models.Model):
editable_answers = models.BooleanField(_("Answers can be edited after submission"), default=True)
publish_date = models.DateTimeField(_("Date that survey was made available"))
expire_date = models.DateTimeField(_("Expiry date of survey"))
public_url = models.CharField(_("Public URL"), max_length=255, default='') # TODO: [manuel] this should be auto-generated at the creation of the survey using an UUID
public_url = models.CharField(_("Public URL"), max_length=255, blank=True) # TODO: [manuel] this should be auto-generated when chosen by the designer
designer = models.ForeignKey(User, on_delete=models.CASCADE, default=1)

def __str__(self):
Expand Down
1 change: 1 addition & 0 deletions citizenvoice/apiapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ def submit_response(self, request, *args, **kwargs):
print("Submitting response...")

# TODO: test submision using this endpoint
# TODO: this is already possible via the answers endpoint
user = self.request.user
answers = self.request.data["answers"]
responseId = self.request.data["responseId"]
Expand Down
9 changes: 6 additions & 3 deletions citizenvoice/citizenvoice/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

# read environment variable form .env file
load_dotenv("../.env")

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv('SECRET_KEY')


# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

Expand Down Expand Up @@ -84,16 +88,15 @@
# CORS
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

CORS_ORIGIN_WHITELIST = (
CORS_ORIGIN_WHITELIST = [
'http://localhost:3000',
)
]

CSRF_TRUSTED_ORIGINS = ['http://localhost:3000']

Expand Down
Loading

0 comments on commit 781d581

Please sign in to comment.