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(){ Jméno Příjmení + Telefon Email PSČ Město @@ -55,6 +56,7 @@ $(document).ready(function(){ {{p.first_name}} {{p.last_name}} + {{p.phone}} {{p.email}} {{p.postcode|default_if_none:'-'}} {{p.city|default_if_none:'-'}} diff --git a/nalodeni/templates/people/pending.html b/nalodeni/templates/people/pending.html index d0cd267..915bfbc 100644 --- a/nalodeni/templates/people/pending.html +++ b/nalodeni/templates/people/pending.html @@ -29,6 +29,7 @@ $(document).ready(function(){ Datum registrace E-mail Registrační zpráva ? + Telefon PSČ Uživatel chce Poznámka, vzkaz @@ -40,6 +41,7 @@ $(document).ready(function(){ {{p.email}} {%if p.emailToken %}{%if p.etStamp > tokenValidAfter %}platná{%else%}vypršela{%endif%}{%else%}ne{%endif%} {{p.etStamp | date:'j.n, H:i'}} + {{p.phone|default_if_none:'-'}} {{p.postcode|default_if_none:'-'}} {{p.get_kind_display}} {{p.interestedIn|default_if_none:'-'}} diff --git a/nalodeni/templates/person/detail.html b/nalodeni/templates/person/detail.html index f0b26e2..14b28b5 100644 --- a/nalodeni/templates/person/detail.html +++ b/nalodeni/templates/person/detail.html @@ -20,6 +20,7 @@ + diff --git a/nalodeni/templates/profil.html b/nalodeni/templates/profil.html index 0927d71..58d66cb 100644 --- a/nalodeni/templates/profil.html +++ b/nalodeni/templates/profil.html @@ -46,6 +46,7 @@ Usnadní rovněž zapojení do pirátských aktivit krajských sdružení (KS) a místních sdružení (MS).
+
{{form.phone.label}}
{{form.phone.errors}}{{form.phone}}
{{form.district.label}}
{{form.district.errors}}{{form.district}}
{{form.city.label}}
{{form.city.errors}}{{form.city}}
{{form.postcode.label}}
{{form.postcode.errors}}{{form.postcode}}
diff --git a/nalodeni/views.py b/nalodeni/views.py index 862f87b..8d05394 100644 --- a/nalodeni/views.py +++ b/nalodeni/views.py @@ -476,13 +476,10 @@ def email_vizitka(request): initial={'name': '%s %s' % (request.user.firstName, request.user.lastName) } ) - - template = 'nastenka/email_vizitka.html' context = { 'form' : form, } - - return render(request, template, context) + return render(request, 'nastenka/email_vizitka.html', context) @login_required(login_url="/prihlaseni")
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}}