@@ -49,8 +49,9 @@ def get_available_name(self, name, max_length=None):
4949
5050class Municipality (models .Model ):
5151 class Meta :
52- verbose_name_plural = 'municipalities'
52+ verbose_name_plural = _ ( 'municipalities' )
5353 ordering = ['name' ]
54+ verbose_name = _ ("municipality" )
5455
5556 CANTONS_CHOICES = [
5657 ('GR' , 'Graubünden' ),
@@ -117,6 +118,8 @@ class SnapshotPermission(IntFlag):
117118class Snapshot (models .Model ):
118119 class Meta :
119120 ordering = ['-created' ]
121+ verbose_name = _ ("snapshot" )
122+ verbose_name_plural = _ ("snapshots" )
120123
121124 id = models .CharField (
122125 max_length = 8 , unique = True ,
@@ -324,27 +327,28 @@ def resave(sender, instance, created, **kwargs):
324327
325328class Category (TranslatableModel ):
326329 class Meta :
327- verbose_name_plural = 'categories'
330+ verbose_name_plural = _ ( 'categories' )
328331 ordering = ['namespace' ]
332+ verbose_name = _ ("category" )
329333
330- created = models .DateTimeField (auto_now_add = True )
331- modified = models .DateTimeField (auto_now = True )
332- deleted = models .BooleanField (default = False )
334+ created = models .DateTimeField (_ ( "created" ), auto_now_add = True )
335+ modified = models .DateTimeField (_ ( "modified" ), auto_now = True )
336+ deleted = models .BooleanField (_ ( "deleted" ), default = False )
333337
334338 # my_order = models.PositiveIntegerField(default=0, blank=False, null=False)
335- hide_in_list = models .BooleanField (default = False )
339+ hide_in_list = models .BooleanField (_ ( "hide in list" ), default = False )
336340
337341 namespace = models .CharField (max_length = 255 , default = 'core/beteiligung' )
338- icon = models .FileField (upload_to = 'category-icons' , null = True , blank = True )
339- color = models .CharField (max_length = 7 , default = '#cccccc' )
342+ icon = models .FileField (_ ( "icon" ), upload_to = 'category-icons' , null = True , blank = True )
343+ color = models .CharField (_ ( "color" ), max_length = 7 , default = '#cccccc' )
340344
341345 group = models .ForeignKey (
342346 Group , default = None , blank = True ,
343347 null = True , on_delete = models .SET_NULL
344348 )
345349
346350 translations = TranslatedFields (
347- name = models .CharField (max_length = 255 ),
351+ name = models .CharField (_ ( "name" ), max_length = 255 ),
348352 )
349353 # workspace = models.ForeignKey(Workspace, on_delete=models.CASCADE)
350354
@@ -355,12 +359,13 @@ def __str__(self):
355359
356360class Usergroup (TranslatableModel ):
357361 class Meta :
358- verbose_name_plural = 'usergroups'
362+ verbose_name_plural = _ ('usergroups' )
363+ verbose_name = _ ("usergroup" )
359364 # ordering = ['name']
360365
361- created = models .DateTimeField (auto_now_add = True )
362- modified = models .DateTimeField (auto_now = True )
363- deleted = models .BooleanField (default = False )
366+ created = models .DateTimeField (_ ( "created" ), auto_now_add = True )
367+ modified = models .DateTimeField (_ ( "modified" ), auto_now = True )
368+ deleted = models .BooleanField (_ ( "deleted" ), default = False )
364369
365370 key = models .CharField (
366371 max_length = 50 , unique = True ,
@@ -373,7 +378,7 @@ class Meta:
373378 )
374379
375380 translations = TranslatedFields (
376- name = models .CharField (max_length = 255 ),
381+ name = models .CharField (_ ( "name" ), max_length = 255 ),
377382 )
378383
379384 def __str__ (self ):
@@ -384,6 +389,8 @@ def __str__(self):
384389class Workspace (TranslatableModel ):
385390 class Meta :
386391 ordering = ['-created' ]
392+ verbose_name = _ ("workspace" )
393+ verbose_name_plural = _ ("workspaces" )
387394
388395 id = models .CharField (
389396 max_length = 8 , unique = True ,
@@ -404,7 +411,7 @@ class Meta:
404411 ]
405412 mode = models .CharField (max_length = 3 , choices = MODE_CHOICES , default = "OFF" )
406413
407- group = models .ForeignKey (
414+ group = models .ForeignKey (
408415 Group , default = None , blank = True ,
409416 null = True , on_delete = models .SET_NULL
410417 )
@@ -459,21 +466,23 @@ class Annotation(models.Model):
459466 class Meta :
460467 ordering = ['-created' ]
461468 permissions = [
462- ('publish_annotation' , 'Can publish annotations' ),
463- ('export_annotation' , 'Can export annotations' ),
469+ ('publish_annotation' , _ ( 'Can publish annotations' ) ),
470+ ('export_annotation' , _ ( 'Can export annotations' ) ),
464471 ]
472+ verbose_name = _ ("annotation" )
473+ verbose_name_plural = _ ("annotations" )
465474
466- created = models .DateTimeField (auto_now_add = True )
467- modified = models .DateTimeField (auto_now = True )
468- deleted = models .BooleanField (default = False )
469- public = models .BooleanField (default = False )
475+ created = models .DateTimeField (_ ( "created" ), auto_now_add = True )
476+ modified = models .DateTimeField (_ ( "modified" ), auto_now = True )
477+ deleted = models .BooleanField (_ ( "deleted" ), default = False )
478+ public = models .BooleanField (_ ( "public" ), default = False )
470479
471480 KIND_CHOICES = [
472- ('COM' , 'Comment' ),
473- ('PLY' , 'Polygon' ),
481+ ('COM' , _ ( 'Comment' ) ),
482+ ('PLY' , _ ( 'Polygon' ) ),
474483 ]
475- kind = models .CharField (max_length = 3 , choices = KIND_CHOICES )
476- data = models .JSONField (default = dict )
484+ kind = models .CharField (_ ( "kind" ), max_length = 3 , choices = KIND_CHOICES )
485+ data = models .JSONField (_ ( "data" ), default = dict )
477486 category = models .ForeignKey (
478487 Category , default = None , blank = True ,
479488 null = True , on_delete = models .SET_NULL
@@ -482,8 +491,8 @@ class Meta:
482491 Usergroup , default = None , blank = True ,
483492 null = True , on_delete = models .SET_NULL
484493 )
485- author_email = models .EmailField (max_length = 254 )
486- rating = models .DecimalField (default = 0 , decimal_places = 2 , max_digits = 6 )
494+ author_email = models .EmailField (_ ( "author email" ), max_length = 254 )
495+ rating = models .DecimalField (_ ( "rating" ), default = 0 , decimal_places = 2 , max_digits = 6 )
487496 workspace = models .ForeignKey (Workspace , on_delete = models .CASCADE )
488497
489498 def save (self , * args , ** kwargs ):
@@ -540,6 +549,8 @@ def __str__(self):
540549class Attachement (models .Model ):
541550 class Meta :
542551 ordering = ['my_order' ]
552+ verbose_name = _ ("attachment" )
553+ verbose_name_plural = _ ("attachments" )
543554
544555 created = models .DateTimeField (auto_now_add = True )
545556 modified = models .DateTimeField (auto_now = True )
@@ -553,26 +564,26 @@ class Meta:
553564@receiver (post_save , sender = Annotation )
554565def send_new_annotation_email (sender , instance , created , ** kwargs ):
555566
556- if created :
567+ if created and instance . author_email :
557568 recipient = instance .author_email
558- subject = 'Kommentar freischalten'
559- message = 'Besten Dank für Ihren Kommentar!\n '
569+ subject = _ ( 'Kommentar freischalten' )
570+ message = _ ( 'Besten Dank für Ihren Kommentar!\n ' )
560571
561572 website = get_website (Site .objects .get_current ())
562573
563- if instance .workspace .annotations_open :
574+ if instance .workspace .annotations_open or instance . workspace . polygon_open :
564575 idstr = str (instance .id )
565576
566577 uniquestr = recipient + idstr + SECRET_KEY
567578 publishKeyHex = hashlib .md5 (uniquestr .encode ()).hexdigest ()
568579 publish_url = reverse ('annotation-publish' , args = [idstr , publishKeyHex ])
569580
570- message += 'Sie können ihn unter folgender URL freischalten:\n '
571- message += f'{ website ["base" ]} { publish_url } \n '
581+ message += _ ( 'Sie können ihn unter folgender URL freischalten:\n ' )
582+ message += _ ( f'{ website ["base" ]} { publish_url } \n ' )
572583 message += '--' * 30
573584 else :
574- message += "Leider ist die Beteiligung nun abgeschlossen.\n "
575- message += f"Zur Karte mit allen öffentlichen Kommentaren: { website ['base' ]} /de/{ instance .workspace .pk } /{ instance .workspace .snapshots .first ().pk } /"
585+ message += _ ( "Leider ist die Beteiligung nun abgeschlossen.\n " )
586+ message += _ ( f"Zur Karte mit allen öffentlichen Kommentaren: { website ['base' ]} /de/{ instance .workspace .pk } /{ instance .workspace .snapshots .first ().pk } /" )
576587 message += '--' * 30
577588
578589 send_mail (
0 commit comments