NEW: Telefon do CSV exportu lidi, FIX: KEyError pri neexistujicim kraji tamtez

This commit is contained in:
Jarmil 2019-12-12 10:19:30 +01:00
parent 27ce8e204b
commit cb441872ec
2 changed files with 22 additions and 11 deletions

View File

@ -249,10 +249,19 @@ class AppUser(AbstractUser, DataAudited):
@consent_terms.setter
def consent_terms(self, value):
writeUserSetting(self, 'consent_terms', value, datetime.date)
# properties mimo model
def get_district_name(self):
""" Vrat nazev kraje - textova reprezentace, muze se menit, nepouzivat jako klic """
try:
ret = self.DISTRICT_CHOICES_STR[self.district]
except KeyError:
ret = "- Nezadán -"
return ret
# Meta
def __str__(self):
return self.username

View File

@ -122,7 +122,7 @@ def eu2019(request, dist=None):
row[0] = obj.id
row[1] = obj.createdStamp
row[2] = obj.email
row[3] = models.AppUser.DISTRICT_CHOICES_STR[obj.district] if obj.district else None
row[3] = obj.get_district_name()
row[4] = obj.postcode
row[5] = 1 if obj.want_info else 0
row[6] = 1 if obj.want_campaign else 0
@ -172,6 +172,7 @@ def confirmed(request, newOnly=False, dist=None):
"Příjmení",
"E-mail registrační",
"E-mail kontaktní",
"Telefon",
"Kraj",
"PSČ",
"Město",
@ -202,14 +203,15 @@ def confirmed(request, newOnly=False, dist=None):
row[2] = obj.last_name
row[3] = obj.email
row[4] = obj.email_contact_active
row[5] = obj.DISTRICT_CHOICES_STR[obj.district]
row[6] = obj.postcode
row[7] = obj.city
row[8] = obj.KIND_CHOICES_STR[obj.kind]
row[9] = obj.interestedIn
row[10] = obj.STATUS_CHOICES_STR[obj.status]
row[11] = obj.dc_stamp
row[12] = obj.userform.skills_note if obj.userform else None
row[5] = obj.phone
row[6] = obj.get_district_name()
row[7] = obj.postcode
row[8] = obj.city
row[9] = obj.KIND_CHOICES_STR[obj.kind]
row[10] = obj.interestedIn
row[11] = obj.STATUS_CHOICES_STR[obj.status]
row[12] = obj.dc_stamp
row[13] = obj.userform.skills_note if obj.userform else None
if obj.userform:
for abbr, mdl in [