| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
from EmailReminder.Utils import EMAIL_REGEX, readXMLValue, writeXMLValue |
| 19 |
from EmailReminder.Yearly import YearlyModel |
| 20 |
|
| 21 |
|
| 22 |
class BirthdayModel(YearlyModel): |
| 23 |
LABEL = 'Birthdays' |
| 24 |
TYPE = 'birthday' |
| 25 |
COLUMN_NAMES = ["Name", "Birth Date", "Email"] |
| 26 |
|
| 27 |
def fillNewEvent(self, event): |
| 28 |
super().fillNewEvent(event) |
| 29 |
writeXMLValue(self.document, event, 'email', '') |
| 30 |
|
| 31 |
def getDataInternal(self, column, row): |
| 32 |
parentData = super().getDataInternal(column, row) |
| 33 |
if parentData: |
| 34 |
return parentData |
| 35 |
if column == 2: |
| 36 |
return readXMLValue(self.events[row], 'email') |
| 37 |
|
| 38 |
return None |
| 39 |
|
| 40 |
def setDataInternal(self, column, row, value): |
| 41 |
if column == 2: |
| 42 |
if not EMAIL_REGEX.fullmatch(value): |
| 43 |
value = '' |
| 44 |
writeXMLValue(self.document, self.events[row], 'email', value) |
| 45 |
else: |
| 46 |
super().setDataInternal(column, row, value) |