diff --git a/nalodeni/auth.py b/nalodeni/auth.py index 0b28ae3..fdf8d15 100644 --- a/nalodeni/auth.py +++ b/nalodeni/auth.py @@ -20,11 +20,12 @@ logger = logging.getLogger(__name__) # Our user model USER_MODEL = get_user_model() + class EmailTokenAuthBackend: """ Provides authorization via email workflow. - The user is verified by a token previously sent by email. + Zde se take vytvari skutecny uzivatel (model AppUser) z registrovaneho (model AppRegEmail) """ def get_user(self, user_id): @@ -76,6 +77,7 @@ class EmailTokenAuthBackend: u = USER_MODEL() u.username = reg.email u.email = reg.email + u.phone = reg.phone u.postcode = reg.postcode u.kind = reg.kind u.interestedIn = reg.interestedIn @@ -98,6 +100,7 @@ class EmailTokenAuthBackend: return None + def sendLoginToken(user): """ Generate and send a token to the user. diff --git a/nalodeni/forms.py b/nalodeni/forms.py index 8dcd097..4f59499 100644 --- a/nalodeni/forms.py +++ b/nalodeni/forms.py @@ -18,7 +18,7 @@ class AppUserForm(ModelForm): class Meta: model = models.AppUser - fields = ['first_name','last_name', + fields = ['first_name','last_name', 'phone', 'city', 'postcode', 'district', 'kind', 'email', 'email_contact', 'email_contact_active', 'dc_stamp', 'admin_note'] @@ -61,7 +61,7 @@ class AppUserSsoForm(ModelForm): class Meta: model = models.AppUser fields = ['city', 'postcode', 'district', 'kind', - 'email', 'email_contact', 'email_contact_active', 'dc_stamp' ] + 'phone', 'email', 'email_contact', 'email_contact_active', 'dc_stamp' ] def clean_postcode(self): data = self.cleaned_data['postcode'] @@ -96,7 +96,7 @@ class AppUserSsoForm(ModelForm): class AppRegEmailForm(ModelForm): class Meta: model = models.AppRegEmail - fields = ['email', 'postcode', 'kind', 'interestedIn', 'data_consent'] + fields = ['email', 'phone', 'postcode', 'kind', 'interestedIn', 'data_consent'] def clean_postcode(self): data = self.cleaned_data['postcode'] diff --git a/nalodeni/migrations/0059_appregemail_phone.py b/nalodeni/migrations/0059_appregemail_phone.py new file mode 100644 index 0000000..e56c2c2 --- /dev/null +++ b/nalodeni/migrations/0059_appregemail_phone.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0.3 on 2019-11-19 09:56 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('nalodeni', '0058_appuser_dc_undo_stamp'), + ] + + operations = [ + migrations.AddField( + model_name='appregemail', + name='phone', + field=models.CharField(blank=True, max_length=30, verbose_name='Telefon'), + ), + ] diff --git a/nalodeni/migrations/0060_appuser_phone.py b/nalodeni/migrations/0060_appuser_phone.py new file mode 100644 index 0000000..a5c28d7 --- /dev/null +++ b/nalodeni/migrations/0060_appuser_phone.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0.3 on 2019-11-19 10:03 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('nalodeni', '0059_appregemail_phone'), + ] + + operations = [ + migrations.AddField( + model_name='appuser', + name='phone', + field=models.CharField(blank=True, max_length=30, verbose_name='Telefon'), + ), + ] diff --git a/nalodeni/models.py b/nalodeni/models.py index dc4d440..f1bf47f 100644 --- a/nalodeni/models.py +++ b/nalodeni/models.py @@ -151,6 +151,7 @@ class AppUser(AbstractUser, DataAudited): postcode = IntegerField(_('PSČ'), blank=False, null=True) city = CharField(_(u'Město'), max_length=120, default=None, blank=True, null=True) district = IntegerField(_('Kraj'), blank=True, null=True, choices=DISTRICT_CHOICES, default=None) + phone = CharField(_('Telefon'), max_length=30, blank=True) # Stav KIND_MEMBER se nastavuje dle skutečného členství, a bude # pravidelně aktualizován synchronizací s DB členů. @@ -384,8 +385,9 @@ class AppRegEmail(Model): createdStamp = DateTimeField(_('Uživatel vytvořen'), default=datetime.datetime.now, blank=False, null=False, editable=False) - email = CharField(_('e-mail'),max_length=100, default='', blank=True, null=True) + email = CharField(_('e-mail'), max_length=100, default='', blank=True, null=True) postcode = IntegerField(_('PSČ (kvůli dělení do krajů)'), blank=False, null=True) + phone = CharField(_('Telefon'), max_length=30, blank=True) kind = IntegerField(_('Chci'), blank=True, null=True, default = AppUser.KIND_NEWSLETTER, choices=AppUser.KIND_CHOICES) diff --git a/nalodeni/templates/people/list.html b/nalodeni/templates/people/list.html index b87da2e..5df91c0 100644 --- a/nalodeni/templates/people/list.html +++ b/nalodeni/templates/people/list.html @@ -40,6 +40,7 @@ $(document).ready(function(){
Uživ. jméno (login) | {{obj.username}} |
---|---|
Jméno a příjmení | {{obj.first_name|default_if_none:'-'}} {{obj.last_name|default_if_none:'-'}} |
Telefon | {{obj.phone}} |
Město, PSČ, Kraj, Okres | {{obj.city|default_if_none:'-'}}, {{obj.postcode|default_if_none:'-'}}, {{obj.get_district_display|default_if_none:'-'}}, {{obj.county|default_if_none:'-'}} |
Reg. e-mail | {{obj.email}} |