Commit e8753c8d authored by Thomas Frion's avatar Thomas Frion

[UPDF] Add properties to GendUnit

parent 8a9a298d
......@@ -53,22 +53,24 @@ class UnitAdmin(admin.OSMGeoAdmin): # We use the OpenStreet Map Admin model
@admin.register(GendUnit)
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')
ordering = ('code', 'name', 'email', 'dept')
# Column of the list
list_display = ('code', 'name', 'email', 'addr')
list_display = ('code', 'name', 'email', 'addr', 'dept', 'phone')
# Fields used by the search bar
search_fields = ('code', 'name', 'email', 'addr')
search_fields = ('code', 'name', 'email', 'addr', 'dept', 'phone')
# We create groups to structure the forms
fieldsets = (
('Unité', {'fields': ('code', 'name', 'email')}),
('Localisation', {'fields': ('addr','geom')}),
('Unité', {'fields': ('code', 'name', 'email', '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')}),
('Localisation', {'fields': ('addr','geom')})
('Unité', {'fields': ('code', 'name', 'email', 'phone')}),
('Localisation', {'fields': ('addr', 'dept','geom')})
)
form = GendUnitForm
......
......@@ -95,6 +95,11 @@ class GendUnitCreationForm(forms.ModelForm):
widget=forms.Textarea
)
dept = forms.CharField(
label="Departement",
max_length=3,
)
geom = forms.PointField(
label="Location",
widget=forms.OSMWidget(
......@@ -133,6 +138,11 @@ class GendUnitForm(forms.ModelForm):
widget=forms.Textarea
)
dept = forms.CharField(
label="Departement",
max_length=3,
)
geom = forms.PointField(
label="Location",
widget=forms.OSMWidget(
......
# Generated by Django 3.0.4 on 2020-05-26 06:51
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('unit', '0003_auto_20200526_0814'),
]
operations = [
migrations.AddField(
model_name='gendunit',
name='dept',
field=models.CharField(blank=True, max_length=3, null=True),
),
migrations.AddField(
model_name='gendunit',
name='phone',
field=models.CharField(blank=True, max_length=20, null=True),
),
]
......@@ -49,6 +49,8 @@ class GendUnit(models.Model):
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)
dept = models.CharField(max_length=3, blank=True, null=True)
phone = models.CharField(max_length=20, blank=True, null=True)
def __str__(self):
return self.code + ' : ' + self.name
......
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