Commit 017312ed authored by Thomas Frion's avatar Thomas Frion

[FIX|WIP] Fix a form issue (wrong field name)

 * Fix issue of GendUnit forms
 * Update model of GendUnit to determine which field is required or not
 * Create fixture
parent e8753c8d
......@@ -110,7 +110,7 @@ SERIALIZATION_MODULES = {
}
FIXTURE_DIRS = (
'/path/to/myapp/fixtures/',
'./fixtures/',
)
ROOT_URLCONF = 'choucas.urls'
......
[{"model": "external_service.externalservice", "pk": 2, "fields": {"name": "IGN", "baseUrl": "http://wxs.ign.fr/{key}/geoportail/wmts", "key": "2pkukowxt0podbngs5sckjry", "desc": ""}}, {"model": "external_service.externalservice", "pk": 3, "fields": {"name": "OTM", "baseUrl": "https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", "key": "", "desc": ""}}, {"model": "external_service.externalservice", "pk": 4, "fields": {"name": "OSM", "baseUrl": "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", "key": "", "desc": ""}}, {"model": "external_service.externalservicesetting", "pk": 3, "fields": {"name": "layer_maps", "value": "GEOGRAPHICALGRIDSYSTEMS.MAPS", "service": 2}}, {"model": "external_service.externalservicesetting", "pk": 4, "fields": {"name": "layer_photo", "value": "ORTHOIMAGERY.ORTHOPHOTOS", "service": 2}}, {"model": "external_service.externalservicesetting", "pk": 5, "fields": {"name": "url_params", "value": "&service=WMTS&request=GetTile&version=1.0.0&style=normal&tilematrixset=PM&format=image/jpeg&tilematrix={z}&tilerow={y}&tilecol={x}", "service": 2}}, {"model": "external_service.externalservicesetting", "pk": 6, "fields": {"name": "attribution", "value": "&copy; <a href=\"http://garmin.opentopomap.org/#right\">OpentTopoMap</a> | Choucas", "service": 3}}, {"model": "external_service.externalservicesetting", "pk": 7, "fields": {"name": "attribution", "value": "&copy; <a href=\"http://www.openstreetmap.org/copyright\" target=\"_blank\"> OpenStreetMap</a> contributors | Choucas", "service": 4}}, {"model": "external_service.externalservicesetting", "pk": 8, "fields": {"name": "attribution", "value": "Choucas | <a href=\"http://www.ign.fr/\" target=\"_blank\">IGN-F/Geoportail</a>", "service": 2}}]
\ No newline at end of file
[{"model": "pghm.unit", "pk": 1, "fields": {"code": "PG38", "nom": "PGHM ISERE", "email": "pghm.le-versoud@gendarmerie.interieur.gouv.fr", "geom": "SRID=4326;POINT (5.850563049316404 45.21808242410029)", "dept": "38"}}, {"model": "pghm.settingunit", "pk": 1, "fields": {"name": "Zoom", "value": "\u00e7", "unit": "PG38"}}, {"model": "pghm.settingunit", "pk": 2, "fields": {"name": "Test", "value": "dfs", "unit": "PG38"}}, {"model": "pghm.pghmuser", "pk": 1, "fields": {"user": 1, "unit": 1}}, {"model": "pghm.webcam", "pk": 1, "fields": {"name": "LE PLEYNET \u2013 SOMMET DE L\u2019OURSIERE", "station": "Les 7 Laux", "site": "https://www.skaping.com/les7laux/pleynet/oursiere", "img": null, "location": "SRID=4326;POINT (6.032351105564849 45.25316670880032)"}}, {"model": "pghm.webcam", "pk": 2, "fields": {"name": "D\u00e9part Crolles", "station": "Le Grand Revard", "site": "", "img": "", "location": "SRID=4326;POINT (5.982971348306217 45.68622369792225)"}}, {"model": "pghm.webcam", "pk": 3, "fields": {"name": "Le Belv\u00e9d\u00e8re", "station": "Le Grand Revard", "site": "", "img": "", "location": "SRID=4326;POINT (5.975914159051984 45.68002746779146)"}}, {"model": "pghm.externalservice", "pk": 1, "fields": {"name": "IGN", "baseUrl": "http://wxs.ign.fr/{key}/geoportail/wmts", "key": "2pkukowxt0podbngs5sckjry"}}, {"model": "pghm.externalservicesetting", "pk": 1, "fields": {"name": "service", "value": "&service=WMTS&request=GetTile&version=1.0.0&style=normal&tilematrixset=PM&format=image/jpeg&tilematrix={z}&tilerow={y}&tilecol={x}", "service": 1}}]
\ No newline at end of file
[{"model": "pghm.pghmuser", "pk": 1, "fields": {"user": 1, "unit": 1}}]
\ No newline at end of file
......@@ -56,26 +56,26 @@ class GendUnitAdmin(admin.ModelAdmin):
# Fields to which filters can be applied
list_filter = ('dept',) # Keep the comma, ovewise there will be an error
# Fields used to order the list
ordering = ('code', 'name', 'email', 'dept')
ordering = ('code', 'name', 'dept')
# Column of the list
list_display = ('code', 'name', 'email', 'addr', 'dept', 'phone')
list_display = ('code', 'name', 'addr', 'dept', 'phone')
# Fields used by the search bar
search_fields = ('code', 'name', 'email', 'addr', 'dept', 'phone')
search_fields = ('code', 'name', 'addr', 'dept', 'phone')
# We create groups to structure the forms
fieldsets = (
('Unité', {'fields': ('code', 'name', 'email', 'phone')}),
('Unité', {'fields': ('code', 'name', 'phone')}),
('Localisation', {'fields': ('addr', 'dept','geom')}),
)
# We create groups and we select the fields for the Add form
add_fieldsets = (
('Unité', {'fields': ('code', 'name', 'email', 'phone')}),
('Unité', {'fields': ('code', 'name', 'phone')}),
('Localisation', {'fields': ('addr', 'dept','geom')})
)
form = GendUnitForm
# We select the add form
add_form = GendUnitForm
add_form = GendUnitCreationForm
# We get the defined structure
def get_fieldsets(self, request, obj=None):
......
[{"model": "unit.unit", "pk": 1, "fields": {"code": "PG38", "name": "PGHM ISERE", "email": "pghm.le-versoud@gendarmerie.interieur.gouv.fr", "geom": "SRID=4326;POINT (5.852108001708986 45.21880793965786)", "dept": "38"}}, {"model": "unit.settingunit", "pk": 1, "fields": {"name": "Zoom", "value": "12", "unit": "PG38"}}, {"model": "unit.gendunit", "pk": 1, "fields": {"code": "1008930", "name": "Gendarmerie - Brigade de Dom\u00e8ne", "geom": "SRID=4326;POINT (5.838324129581451 45.20430153912546)", "addr": "33 Rue Jules Ferry 38420 DOMENE", "dept": "38", "phone": "+33 4 76 77 24 46"}}]
\ No newline at end of file
......@@ -84,9 +84,9 @@ class GendUnitCreationForm(forms.ModelForm):
max_length=128,
)
email = forms.EmailField(
label="E-mail",
max_length=128,
phone = forms.CharField(
label='Téléphone',
max_length=20,
)
addr = forms.CharField(
......@@ -98,6 +98,7 @@ class GendUnitCreationForm(forms.ModelForm):
dept = forms.CharField(
label="Departement",
max_length=3,
required=False,
)
geom = forms.PointField(
......@@ -122,31 +123,31 @@ class GendUnitForm(forms.ModelForm):
max_length=16,
)
nom = forms.CharField(
name = forms.CharField(
label="Nom",
max_length=128,
)
email = forms.EmailField(
label="E-mail",
max_length=128,
phone = forms.CharField(
label='Téléphone',
max_length=20,
required=False,
)
addr = forms.CharField(
label="Adresse",
required=False,
widget=forms.Textarea
)
dept = forms.CharField(
label="Departement",
max_length=3,
required=False,
)
geom = forms.PointField(
label="Location",
widget=forms.OSMWidget(
)
)
......
# Generated by Django 3.0.4 on 2020-05-26 07:17
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('unit', '0004_auto_20200526_0851'),
]
operations = [
migrations.RemoveField(
model_name='gendunit',
name='email',
),
]
......@@ -46,9 +46,8 @@ class SettingUnit(models.Model):
class GendUnit(models.Model):
code = models.CharField(max_length=16, unique = True)
name = models.CharField(max_length=128)
email = models.EmailField(max_length=128, unique = True, blank=True, null=True)
geom = models.PointField(blank=True, null=True)
addr = models.TextField(blank=True,null=True)
geom = models.PointField()
addr = models.TextField()
dept = models.CharField(max_length=3, blank=True, null=True)
phone = models.CharField(max_length=20, blank=True, null=True)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment