Commit f1630144 authored by Thomas Frion's avatar Thomas Frion

[FEAT] Use verbose_name property to remove the forms. Set language of the...

[FEAT] Use verbose_name property to remove the forms. Set language of the application (switch to french)
parent fd9e6bc8
......@@ -173,7 +173,7 @@ AUTH_PASSWORD_VALIDATORS = [
# Internationalization
# https://docs.djangoproject.com/en/1.9/topics/i18n/
LANGUAGE_CODE = 'en-us'
LANGUAGE_CODE = 'fr-fr'
TIME_ZONE = 'Europe/Paris'
......
default_app_config = 'external_service.apps.ExternalServiceConfig'
\ No newline at end of file
from django.contrib.gis import admin
from external_service.forms import *
from external_service.models import *
class ExternalServiceSettingInline(admin.TabularInline):
......@@ -29,20 +28,8 @@ class ExternalServiceAdmin(admin.ModelAdmin):
("Service", {'fields': ('name', 'baseUrl', 'key', 'desc',)}),
)
form = ExternalServiceForm
add_form = ExternalServiceForm
# We get the defined structure
def get_fieldsets(self, request, obj=None):
if not obj:
return self.add_fieldsets
return super().get_fieldsets(request, obj)
# We get the creation form
def get_form(self, request, obj=None, **kwargs):
defaults = {}
if obj is None:
defaults['form'] = self.add_form
defaults.update(kwargs)
return super().get_form(request, obj, **defaults)
return super().get_fieldsets(request, obj)
\ No newline at end of file
......@@ -3,3 +3,4 @@ from django.apps import AppConfig
class ExternalServiceConfig(AppConfig):
name = 'external_service'
verbose_name = "Services extérieurs"
from django.contrib.gis import forms
from external_service.models import *
class ExternalServiceForm(forms.ModelForm):
name = forms.CharField(
label='Nom',
max_length=1024
)
baseUrl = forms.CharField(
label='URL',
max_length=2048
)
key = forms.CharField(
label='Clef',
max_length=1024,
required=False,
)
desc = forms.CharField(
label='Description',
required=False,
widget=forms.Textarea
)
class Meta:
model = ExternalService
exclude = ()
\ No newline at end of file
......@@ -4,30 +4,33 @@ from django.contrib.gis.db import models
# This class allows to manage the different external services such as IGN API
class ExternalService(models.Model):
name = models.CharField(max_length=1024) # Name of the service
baseUrl = models.CharField(max_length=2048) # Base url of the service
name = models.CharField(max_length=1024, verbose_name="Nom") # Name of the service
baseUrl = models.CharField(max_length=2048, verbose_name="URL de base") # Base url of the service
# Key of the service if the authentication ask for a key
key = models.CharField(max_length=1024, blank=True, null=True)
key = models.CharField(max_length=1024, blank=True, null=True, verbose_name="Clef d'accès")
# Description of the service
desc = models.TextField(blank=True, null=True)
desc = models.TextField(blank=True, null=True, verbose_name="Description")
def __str__(self):
return self.name
class Meta:
managed = True
db_table = 'pghm_external_service'
db_table = 'pghm_external_service'
verbose_name = "Service extérieur"
verbose_name_plural = "Services extérieurs"
# This class save the different parameters of a service that may be requested
class ExternalServiceSetting(models.Model):
name = models.CharField(max_length=256)
value = models.CharField(max_length=1024)
name = models.CharField(max_length=256, verbose_name="Nom")
value = models.CharField(max_length=1024, verbose_name="Valeur")
# Link between this class and ExternalService class
service = models.ForeignKey(
ExternalService,
related_name="serviceSettings", # Relation name
on_delete=models.CASCADE
on_delete=models.CASCADE,
verbose_name="Service extérieur"
)
def __str__(self):
......@@ -35,4 +38,6 @@ class ExternalServiceSetting(models.Model):
class Meta:
managed = True
db_table = 'pghm_external_service_settings'
\ No newline at end of file
db_table = 'pghm_external_service_settings'
verbose_name = "Paramètre du service"
verbose_name_plural = "Paramètres du service"
\ No newline at end of file
default_app_config = 'unit.apps.UnitConfig'
\ No newline at end of file
from django.contrib.gis import admin
from leaflet.admin import LeafletGeoAdmin
from unit.forms import *
from unit.models import *
class SettingUnitInline(admin.TabularInline):
......@@ -34,24 +33,12 @@ class UnitAdmin(LeafletGeoAdmin): # We use the OpenStreet Map Admin model
('Localisation', {'fields': ('dept','geom')})
)
form = UnitForm
# We select the add form
add_form = UnitCreationForm
# We get the defined structure
def get_fieldsets(self, request, obj=None):
if not obj:
return self.add_fieldsets
return super().get_fieldsets(request, obj)
# We get the creation form
def get_form(self, request, obj=None, **kwargs):
defaults = {}
if obj is None:
defaults['form'] = self.add_form
defaults.update(kwargs)
return super().get_form(request, obj, **defaults)
@admin.register(GendUnit)
class GendUnitAdmin(LeafletGeoAdmin):
# Fields to which filters can be applied
......@@ -73,21 +60,9 @@ class GendUnitAdmin(LeafletGeoAdmin):
('Unité', {'fields': ('code', 'name', 'phone')}),
('Localisation', {'fields': ('addr', 'dept','geom')})
)
form = GendUnitForm
# We select the add form
add_form = GendUnitCreationForm
# We get the defined structure
def get_fieldsets(self, request, obj=None):
if not obj:
return self.add_fieldsets
return super().get_fieldsets(request, obj)
# We get the creation form
def get_form(self, request, obj=None, **kwargs):
defaults = {}
if obj is None:
defaults['form'] = self.add_form
defaults.update(kwargs)
return super().get_form(request, obj, **defaults)
\ No newline at end of file
return super().get_fieldsets(request, obj)
\ No newline at end of file
......@@ -3,3 +3,4 @@ from django.apps import AppConfig
class UnitConfig(AppConfig):
name = 'unit'
verbose_name="Unités"
from django.contrib.gis import forms
from unit.models import *
# This form was created to put label.
class UnitCreationForm(forms.ModelForm):
code = forms.CharField(
label="Code",
max_length=16,
)
name = forms.CharField(
label="Nom",
max_length=64,
)
email = forms.EmailField(
label="E-mail",
max_length=64,
)
dept = forms.CharField(
label="Departement",
max_length=3,
)
# geom = forms.PointField(
# label="Location",
# widget=forms.OSMWidget(
# attrs={
# 'default_lon': 2.299281,
# 'default_lat': 47.011913,
# 'default_zoom': 5.4,
# }
# )
# )
class Meta:
model = Unit
exclude = ()
# This form was created to put label.
class UnitForm(forms.ModelForm):
code = forms.CharField(
label="Code",
max_length=16,
)
name = forms.CharField(
label="Nom",
max_length=64,
)
email = forms.EmailField(
label="E-mail",
max_length=64,
)
dept = forms.CharField(
label="Departement",
max_length=3,
)
# geom = forms.PointField(
# label="Location",
# widget=forms.OSMWidget(
# )
# )
class Meta:
model = Unit
exclude = ()
# This form was created to put label.
class GendUnitCreationForm(forms.ModelForm):
code = forms.CharField(
label="Code",
max_length=16,
)
name = forms.CharField(
label="Nom",
max_length=128,
)
phone = forms.CharField(
label='Téléphone',
max_length=20,
)
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(
# attrs={
# 'default_lon': 2.299281,
# 'default_lat': 47.011913,
# 'default_zoom': 5.4,
# }
# )
# )
class Meta:
model = GendUnit
exclude = ()
# This form was created to put label.
class GendUnitForm(forms.ModelForm):
code = forms.CharField(
label="Code",
max_length=16,
)
name = forms.CharField(
label="Nom",
max_length=128,
)
phone = forms.CharField(
label='Téléphone',
max_length=20,
required=False,
)
addr = forms.CharField(
label="Adresse",
widget=forms.Textarea
)
dept = forms.CharField(
label="Departement",
max_length=3,
required=False,
)
# geom = forms.PointField(
# label="Location",
# widget=forms.OSMWidget(
# )
# )
class Meta:
model = GendUnit
exclude = ()
\ No newline at end of file
......@@ -3,11 +3,11 @@ from __future__ import unicode_literals
from django.contrib.gis.db import models
class Unit(models.Model):
code = models.CharField(max_length=16, unique = True)
name = models.CharField(max_length=64)
email = models.EmailField(max_length=64, unique = True)
geom = models.PointField(blank=True, null=True)
dept = models.CharField(max_length=3, blank=True, null=True)
code = models.CharField(max_length=16, unique = True, verbose_name="Code")
name = models.CharField(max_length=64, verbose_name="Name")
email = models.EmailField(max_length=64, unique = True, verbose_name="E-mail")
geom = models.PointField(blank=True, null=True, verbose_name="Localisation")
dept = models.CharField(max_length=3, blank=True, null=True, verbose_name="Département")
def __str__(self):
return self.code + ' : ' + self.name
......@@ -15,6 +15,8 @@ class Unit(models.Model):
class Meta:
managed = True # Allows to write the table (in database)
db_table = 'pghm_unit'
verbose_name = "Unité PGHM"
verbose_name_plural = "Unités PGHM"
class SettingUnit(models.Model):
......@@ -24,15 +26,16 @@ class SettingUnit(models.Model):
# ('Setting name to show','Real setting name'),
)
name = models.CharField(max_length=255,choices=OPTIONS)
value = models.CharField(max_length=1000)
name = models.CharField(max_length=255,choices=OPTIONS, verbose_name="Nom")
value = models.CharField(max_length=1000, verbose_name="Valeur")
unit = models.ForeignKey(
Unit,
# This line below is very important: is the name of the relationship.
# It's will use with serializers
related_name="settings",
to_field='code',
on_delete=models.CASCADE
on_delete=models.CASCADE,
verbose_name= "Unité"
)
def __str__(self):
......@@ -42,18 +45,22 @@ class SettingUnit(models.Model):
managed = True # Allows to write the table (in database)
db_table = 'pghm_unit_settings'
unique_together = (('name','unit'),)
verbose_name = "Paramètre de l'unité"
verbose_name_plural = "Paramètres de l'unité"
class GendUnit(models.Model):
code = models.CharField(max_length=16, unique = True)
name = models.CharField(max_length=128)
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)
code = models.CharField(max_length=16, unique = True, verbose_name="Code")
name = models.CharField(max_length=128, verbose_name="Nom")
geom = models.PointField(verbose_name="Localisation")
addr = models.TextField(verbose_name="Adresse")
dept = models.CharField(max_length=3, blank=True, null=True, verbose_name="Département")
phone = models.CharField(max_length=20, blank=True, null=True, verbose_name="Téléphone")
def __str__(self):
return self.code + ' : ' + self.name
class Meta:
managed = True # Allows to write the table (in database)
db_table = 'gend_unit'
\ No newline at end of file
db_table = 'gend_unit'
verbose_name="Unité de Gendarmerie"
verbose_name_plural="Unités de Gendarmerie"
\ No newline at end of file
default_app_config = 'webcam.apps.WebcamConfig'
\ No newline at end of file
from django.contrib.gis import admin
from leaflet.admin import LeafletGeoAdmin
from webcam.forms import *
from webcam.models import *
@admin.register(Webcam)
......@@ -26,20 +25,9 @@ class WebcamAdmin(LeafletGeoAdmin):
('Localisation', {'fields':('location',)}),
('Paramètres', {'fields':('site','img')})
)
form = WebcamForm
add_form = WebcamForm
# We get the defined structure
def get_fieldsets(self, request, obj=None):
if not obj:
return self.add_fieldsets
return super().get_fieldsets(request, obj)
# We get the creation form
def get_form(self, request, obj=None, **kwargs):
defaults = {}
if obj is None:
defaults['form'] = self.add_form
defaults.update(kwargs)
return super().get_form(request, obj, **defaults)
......@@ -3,3 +3,4 @@ from django.apps import AppConfig
class WebcamConfig(AppConfig):
name = 'webcam'
verbose_name="Webcams"
from django.contrib.gis import forms
# from leaflet.forms.widgets import LeafletWidget
from leaflet.forms.fields import PointField
from leaflet.admin import LeafletWidget
from webcam.models import *
class WebcamForm(forms.ModelForm):
name = forms.CharField(
label="Nom",
max_length=254,
required=True,
)
station = forms.CharField(
label="Station",
max_length=254,
required=True,
)
site = forms.CharField(
label="Site",
max_length=254,
required=False,
)
img = forms.CharField(
label="Image",
max_length=254,
required=False,
)
class Meta:
model = Webcam
exclude = ()
......@@ -4,11 +4,11 @@ from django.contrib.gis.db import models
# Class to manage webcams
class Webcam(models.Model):
name = models.CharField(max_length=254,)
station = models.CharField(max_length=254,)
site = models.CharField(max_length=254,blank=True,null=True)
img = models.CharField(max_length=254,blank=True,null=True)
location = models.PointField(blank=True, null=True)
name = models.CharField(max_length=254, verbose_name="Nom")
station = models.CharField(max_length=254, verbose_name="Station")
site = models.CharField(max_length=254,blank=True,null=True, verbose_name="Site")
img = models.CharField(max_length=254,blank=True,null=True, verbose_name="Image")
location = models.PointField(blank=True, null=True, verbose_name="Localisation")
def __str__(self):
return self.station + ' : ' + self.name
......@@ -16,3 +16,5 @@ class Webcam(models.Model):
class Meta:
managed = True # Allows to write the table (in database)
db_table = 'pghm_webcam'
verbose_name = "Webcam"
verbose_name_plural = "Webcams"
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