Skip to content

Commit

Permalink
Merge pull request #156 from manuGil/devel
Browse files Browse the repository at this point in the history
Include drawing controls to map view in Answers
  • Loading branch information
manuGil authored Mar 18, 2024
2 parents 66f32de + 4011aa8 commit a864edd
Show file tree
Hide file tree
Showing 24 changed files with 647 additions and 159 deletions.
10 changes: 10 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
SECRET_KEY=''
DATABASE_ENGINE='postgis'
POSTGRES_DBASE=''
POSTGRES_USER=''
POSTGRES_PWD=''
POSTGRES_HOST='localhost'
POSTGRES_PORT='5432'
TEST_DBASE=''
API_PARTY_CMS_URL1224=http://127.0.0.1:8000/ # TODO: find where this is used

5 changes: 4 additions & 1 deletion citizenvoice/apiapp/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import django.contrib.auth.models
from django.contrib import auth

from .models import Answer, Question, Survey, Response, PointLocation, PolygonLocation, LineStringLocation, MapView
from .models import ( Answer, Question, Survey, Response, PointLocation,
PolygonLocation, LineStringLocation, MapView,
Location)

# Register the models in the admin site in order to view, create and edit them from the admin page
admin.site.register(Answer)
Expand All @@ -13,6 +15,7 @@
admin.site.register(LineStringLocation)
admin.site.register(PolygonLocation)
admin.site.register(MapView)
admin.site.register(Location)


# Unregister User and Group fields
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 5.0 on 2024-03-13 12:43

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('apiapp', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='linestringlocation',
name='description',
field=models.CharField(blank=True, max_length=100),
),
migrations.AddField(
model_name='pointlocation',
name='description',
field=models.CharField(blank=True, max_length=100),
),
migrations.AddField(
model_name='polygonlocation',
name='description',
field=models.CharField(blank=True, max_length=100),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 5.0 on 2024-03-13 12:44

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('apiapp', '0002_linestringlocation_description_and_more'),
]

operations = [
migrations.RenameField(
model_name='linestringlocation',
old_name='location',
new_name='geometry',
),
migrations.RenameField(
model_name='pointlocation',
old_name='location',
new_name='geometry',
),
migrations.RenameField(
model_name='polygonlocation',
old_name='location',
new_name='geometry',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 5.0 on 2024-03-13 12:46

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('apiapp', '0003_rename_location_linestringlocation_geometry_and_more'),
]

operations = [
migrations.RenameField(
model_name='linestringlocation',
old_name='geometry',
new_name='geom',
),
migrations.RenameField(
model_name='pointlocation',
old_name='geometry',
new_name='geom',
),
migrations.RenameField(
model_name='polygonlocation',
old_name='geometry',
new_name='geom',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 5.0 on 2024-03-13 13:18

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('apiapp', '0004_rename_geometry_linestringlocation_geom_and_more'),
]

operations = [
migrations.AlterField(
model_name='linestringlocation',
name='description',
field=models.CharField(blank=True, max_length=100, null=True),
),
migrations.AlterField(
model_name='pointlocation',
name='description',
field=models.CharField(blank=True, max_length=100, null=True),
),
migrations.AlterField(
model_name='polygonlocation',
name='description',
field=models.CharField(blank=True, max_length=100, null=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Generated by Django 5.0 on 2024-03-13 14:33

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('apiapp', '0005_alter_linestringlocation_description_and_more'),
]

operations = [
migrations.RemoveField(
model_name='linestringlocation',
name='answer',
),
migrations.RemoveField(
model_name='linestringlocation',
name='name',
),
migrations.RemoveField(
model_name='linestringlocation',
name='question',
),
migrations.RemoveField(
model_name='pointlocation',
name='answer',
),
migrations.RemoveField(
model_name='pointlocation',
name='name',
),
migrations.RemoveField(
model_name='pointlocation',
name='question',
),
migrations.RemoveField(
model_name='polygonlocation',
name='answer',
),
migrations.RemoveField(
model_name='polygonlocation',
name='name',
),
migrations.RemoveField(
model_name='polygonlocation',
name='question',
),
migrations.CreateModel(
name='Location',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(blank=True, max_length=100)),
('answer', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='apiapp.answer')),
('lines', models.ManyToManyField(blank=True, to='apiapp.linestringlocation')),
('points', models.ManyToManyField(blank=True, to='apiapp.pointlocation')),
('polygons', models.ManyToManyField(blank=True, to='apiapp.polygonlocation')),
('question', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='apiapp.question')),
],
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.0 on 2024-03-13 16:04

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('apiapp', '0006_remove_linestringlocation_answer_and_more'),
]

operations = [
migrations.RemoveField(
model_name='location',
name='answer',
),
migrations.AddField(
model_name='answer',
name='locations',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='apiapp.location'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 5.0 on 2024-03-15 10:16

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('apiapp', '0007_remove_location_answer_answer_locations'),
]

operations = [
migrations.AlterField(
model_name='location',
name='lines',
field=models.ManyToManyField(blank=True, null=True, to='apiapp.linestringlocation'),
),
migrations.AlterField(
model_name='location',
name='points',
field=models.ManyToManyField(blank=True, null=True, to='apiapp.pointlocation'),
),
migrations.AlterField(
model_name='location',
name='polygons',
field=models.ManyToManyField(blank=True, null=True, to='apiapp.polygonlocation'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Generated by Django 5.0 on 2024-03-15 10:29

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('apiapp', '0008_alter_location_lines_alter_location_points_and_more'),
]

operations = [
migrations.AlterField(
model_name='answer',
name='locations',
field=models.ForeignKey(blank=True, default=1, on_delete=django.db.models.deletion.CASCADE, to='apiapp.location'),
preserve_default=False,
),
migrations.AlterField(
model_name='location',
name='lines',
field=models.ManyToManyField(blank=True, to='apiapp.linestringlocation'),
),
migrations.AlterField(
model_name='location',
name='points',
field=models.ManyToManyField(blank=True, to='apiapp.pointlocation'),
),
migrations.AlterField(
model_name='location',
name='polygons',
field=models.ManyToManyField(blank=True, to='apiapp.polygonlocation'),
),
]
19 changes: 19 additions & 0 deletions citizenvoice/apiapp/migrations/0010_alter_answer_locations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 5.0 on 2024-03-15 10:52

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('apiapp', '0009_alter_answer_locations_alter_location_lines_and_more'),
]

operations = [
migrations.AlterField(
model_name='answer',
name='locations',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='apiapp.location'),
),
]
18 changes: 18 additions & 0 deletions citizenvoice/apiapp/migrations/0011_alter_answer_body.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0 on 2024-03-15 11:00

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('apiapp', '0010_alter_answer_locations'),
]

operations = [
migrations.AlterField(
model_name='answer',
name='body',
field=models.TextField(blank=True, verbose_name='Answer Body'),
),
]
2 changes: 1 addition & 1 deletion citizenvoice/apiapp/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .question import Question
from .response import Response
from .survey import Survey
from .location import PointLocation, PolygonLocation, LineStringLocation
from .location import PointLocation, PolygonLocation, LineStringLocation, Location
from .mapview import MapView

__all__ = ["Answer", "Response", "Survey", "Question", "PointLocation", "PolygonLocation", "LineStringLocation", "MapView"]
9 changes: 5 additions & 4 deletions citizenvoice/apiapp/models/answer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

# from abc import update_abstractmethods
# Import geographic model since we will be saving location data
# from django.contrib.gis.db import models
# from django.contrib.gis.db import moßdels
from django.db import models
from .response import Response
from .question import Question
from .location import Location
from django.utils.translation import gettext_lazy as _



# Represents a single answer given to a certain question as part of a user's response
class Answer(models.Model):
"""
Expand All @@ -23,11 +23,12 @@ class Answer(models.Model):
"""
response = models.ForeignKey(Response, to_field="interview_uuid", on_delete=models.CASCADE) # this field is not inheriting data type. Must be uuid.
question = models.ForeignKey(Question, on_delete=models.CASCADE)
locations = models.ForeignKey(Location, on_delete=models.CASCADE, blank=True, null=True)
created = models.DateTimeField(_("Creation date"), auto_now_add=True)
updated = models.DateTimeField(_("Last edited"), auto_now=True)
body = models.TextField(_("Answer Body"))
body = models.TextField(_("Answer Body"), blank=True)
# TODO: [manuel] Shall we define types for answers?
# location = Location()



def __str__(self):
Expand Down
Loading

0 comments on commit a864edd

Please sign in to comment.