NEW: sbirani a editace telefonniho cisla, viz pozadavek A1

This commit is contained in:
Jarmil 2019-11-19 10:32:26 +01:00
parent 112bdf78c5
commit a24f613b36
10 changed files with 53 additions and 9 deletions

View File

@ -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.

View File

@ -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']

View File

@ -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'),
),
]

View File

@ -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'),
),
]

View File

@ -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)

View File

@ -40,6 +40,7 @@ $(document).ready(function(){
<th><input type="checkbox" id="check_all"/></th>
<th>Jméno</th>
<th>Příjmení</th>
<th>Telefon</th>
<th>Email</th>
<th>PSČ</th>
<th>Město</th>
@ -55,6 +56,7 @@ $(document).ready(function(){
<td><input type="checkbox" name="r[]" value="{{p.id}}"/></td>
<td>{{p.first_name}}</td>
<td>{{p.last_name}}</td>
<td>{{p.phone}}</td>
<td><a href="mailto:{{p.email}}">{{p.email}}</a></td>
<td>{{p.postcode|default_if_none:'-'}}</td>
<td>{{p.city|default_if_none:'-'}}</td>

View File

@ -29,6 +29,7 @@ $(document).ready(function(){
<th>Datum registrace</th>
<th>E-mail</th>
<th title="Byla odeslána registrační zpráva ?" colspan="2">Registrační zpráva ?</th>
<th>Telefon</th>
<th>PSČ</th>
<th>Uživatel chce</th>
<th>Poznámka, vzkaz</th>
@ -40,6 +41,7 @@ $(document).ready(function(){
<td>{{p.email}}</td>
<td>{%if p.emailToken %}{%if p.etStamp > tokenValidAfter %}platná{%else%}vypršela{%endif%}{%else%}ne{%endif%}</td>
<td>{{p.etStamp | date:'j.n, H:i'}}</td>
<td>{{p.phone|default_if_none:'-'}}</td>
<td>{{p.postcode|default_if_none:'-'}}</td>
<td>{{p.get_kind_display}}</td>
<td>{{p.interestedIn|default_if_none:'-'}}</td>

View File

@ -20,6 +20,7 @@
<table style="width: auto;">
<tr><th>Uživ. jméno (login)</th><td>{{obj.username}}</td></tr>
<tr><th>Jméno a příjmení</th><td>{{obj.first_name|default_if_none:'-'}} {{obj.last_name|default_if_none:'-'}}</td></tr>
<tr><th>Telefon</th><td>{{obj.phone}}</td></tr>
<tr><th>Město, PSČ, Kraj, Okres</th><td>{{obj.city|default_if_none:'-'}}, {{obj.postcode|default_if_none:'-'}}, {{obj.get_district_display|default_if_none:'-'}}, {{obj.county|default_if_none:'-'}}</td></tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr><th>Reg. e-mail</th><td>{{obj.email}}</td></tr>

View File

@ -46,6 +46,7 @@
Usnadní rovněž zapojení do pirátských aktivit krajských sdružení (KS) a&nbsp;místních sdružení (MS).
</div>
<div class="medium-12 large-6 columns">
<div ><b>{{form.phone.label}}</b><br/>{{form.phone.errors}}{{form.phone}}</div>
<div ><b>{{form.district.label}}</b><br/>{{form.district.errors}}{{form.district}}</div>
<div ><b>{{form.city.label}}</b><br/>{{form.city.errors}}{{form.city}}</div>
<div ><b>{{form.postcode.label}}</b><br/>{{form.postcode.errors}}{{form.postcode}}</div>

View File

@ -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")