|
13 | 13 |
|
14 | 14 | from django.conf import settings |
15 | 15 | from django.contrib.auth.models import User |
16 | | -from django.core.exceptions import ObjectDoesNotExist |
| 16 | +from django.core.exceptions import ObjectDoesNotExist, ValidationError |
17 | 17 | from django.core.validators import validate_email |
18 | 18 | from django.db import models |
19 | 19 | from django.template.loader import render_to_string |
|
35 | 35 | from ietf.utils.models import ForeignKey, OneToOneField |
36 | 36 |
|
37 | 37 |
|
| 38 | +def name_character_validator(value): |
| 39 | + if '/' in value: |
| 40 | + raise ValidationError('Name cannot contain "/" character.') |
| 41 | + |
| 42 | + |
38 | 43 | class Person(models.Model): |
39 | 44 | history = HistoricalRecords() |
40 | 45 | user = OneToOneField(User, blank=True, null=True, on_delete=models.SET_NULL) |
41 | 46 | time = models.DateTimeField(default=datetime.datetime.now) # When this Person record entered the system |
42 | 47 | # The normal unicode form of the name. This must be |
43 | 48 | # set to the same value as the ascii-form if equal. |
44 | | - name = models.CharField("Full Name (Unicode)", max_length=255, db_index=True, help_text="Preferred long form of name.") |
| 49 | + name = models.CharField("Full Name (Unicode)", max_length=255, db_index=True, help_text="Preferred long form of name.", validators=[name_character_validator]) |
45 | 50 | plain = models.CharField("Plain Name correction (Unicode)", max_length=64, default='', blank=True, help_text="Use this if you have a Spanish double surname. Don't use this for nicknames, and don't use it unless you've actually observed that the datatracker shows your name incorrectly.") |
46 | 51 | # The normal ascii-form of the name. |
47 | 52 | ascii = models.CharField("Full Name (ASCII)", max_length=255, help_text="Name as rendered in ASCII (Latin, unaccented) characters.") |
@@ -262,7 +267,7 @@ def cdn_photo_url(self, size=80): |
262 | 267 |
|
263 | 268 |
|
264 | 269 | class PersonExtResource(models.Model): |
265 | | - person = ForeignKey(Person) |
| 270 | + person = ForeignKey(Person) |
266 | 271 | name = models.ForeignKey(ExtResourceName, on_delete=models.CASCADE) |
267 | 272 | display_name = models.CharField(max_length=255, default='', blank=True) |
268 | 273 | value = models.CharField(max_length=2083) # 2083 is the maximum legal URL length |
@@ -366,7 +371,7 @@ def salt(): |
366 | 371 | ("/api/iesg/position", "/api/iesg/position", "Area Director"), |
367 | 372 | ("/api/v2/person/person", "/api/v2/person/person", "Robot"), |
368 | 373 | ("/api/meeting/session/video/url", "/api/meeting/session/video/url", "Recording Manager"), |
369 | | - ("/api/notify/meeting/registration", "/api/notify/meeting/registration", "Robot"), |
| 374 | + ("/api/notify/meeting/registration", "/api/notify/meeting/registration", "Robot"), |
370 | 375 | ("/api/notify/meeting/bluesheet", "/api/notify/meeting/bluesheet", "Recording Manager"), |
371 | 376 | ("/api/notify/session/attendees", "/api/notify/session/attendees", "Recording Manager"), |
372 | 377 | ("/api/notify/session/chatlog", "/api/notify/session/chatlog", "Recording Manager"), |
@@ -444,4 +449,4 @@ class Meta: |
444 | 449 |
|
445 | 450 | class PersonApiKeyEvent(PersonEvent): |
446 | 451 | key = ForeignKey(PersonalApiKey) |
447 | | - |
| 452 | + |
0 commit comments