-
Notifications
You must be signed in to change notification settings - Fork 0
/
obsolete.py
62 lines (50 loc) · 2.13 KB
/
obsolete.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# -*- coding: UTF-8 -*-
# Copyright (C) 2010 Nicolas Deram <[email protected]>
# Copyright (C) 2010-2011 Hervé Cauwelier <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Import from itools
from itools.core import freeze, merge_dicts
from itools.datatypes import DateTime, Unicode
# Import from ikaaro
from ikaaro.registry import register_resource_class
# Import from crm
from mission import Mission
comment_datatype = Mission.class_schema['comment']
class MissionUpdate(Mission):
class_schema = freeze(merge_dicts(
Mission.class_schema,
comment=comment_datatype(parameters_schema=merge_dicts(
comment_datatype.parameters_schema,
alert_datetime=DateTime,
crm_m_nextaction=Unicode))))
def update_20100927(self):
comments = self.metadata.get_property('comment') or []
# Migrate alert
for comment in reversed(comments):
alert = comment.get_parameter('alert_datetime')
if alert:
self.set_property('crm_m_alert', alert)
# Migrate next action
for comment in reversed(comments):
nextaction = comment.get_parameter('crm_m_nextaction')
if nextaction:
self.set_property('crm_m_nextaction', nextaction)
# Remove parameters
for comment in comments:
comment.set_parameter('alert_datetime', None)
comment.set_parameter('crm_m_nextaction', None)
# Save
self.metadata.set_property('comment', comments)
register_resource_class(MissionUpdate)