Debian Codegraph @

EmailReminder/Anniversary.py

raw symbols SCIP
1 # This file is part of Email-Reminder.
2 #
3 # Copyright (C) 2020 by Francois Marier
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17
18 from EmailReminder.Birthday import BirthdayModel
19 from EmailReminder.Utils import EMAIL_REGEX, readXMLValue, writeXMLValue
20
21
22 class AnniversaryModel(BirthdayModel):
23 LABEL = 'Anniversaries'
24 TYPE = 'anniversary'
25 COLUMN_NAMES = ["Person 1", "Date", "Email 1", "Person 2", "Email 2"]
26
27 def fillNewEvent(self, event):
28 super().fillNewEvent(event)
29 writeXMLValue(self.document, event, 'partner_name', '')
30 writeXMLValue(self.document, event, 'partner_email', '')
31
32 def getDataInternal(self, column, row):
33 parentData = super().getDataInternal(column, row)
34 if parentData:
35 return parentData
36 if column == 3:
37 return readXMLValue(self.events[row], 'partner_name')
38 if column == 4:
39 return readXMLValue(self.events[row], 'partner_email')
40
41 return None
42
43 def setDataInternal(self, column, row, value):
44 if column == 3:
45 writeXMLValue(self.document, self.events[row], 'partner_name',
46 value)
47 elif column == 4:
48 if not EMAIL_REGEX.fullmatch(value):
49 value = ''
50 writeXMLValue(self.document, self.events[row], 'partner_email',
51 value)
52 else:
53 super().setDataInternal(column, row, value)