1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 from timelinelib.db.objects import Container
20 from timelinelib.repositories.dbwrapper import DbWrapperEventRepository
21
22
24 """
25 This controller is responsible for two things:
26 1. creating a new Container event
27 2. updating properties of an existing Container event
28 When creating a new Container event the result is NOT stored in the
29 timeline database. This happens later when the first event added to the
30 container is saved to the database.
31 The reason for this behavior is that we don't want to have empty Conatiners
32 in the database.
33 When updating the properties of an existing Container event the changes
34 are stored in the timeline database.
35 """
36 - def __init__(self, view, db, container):
37 self._set_initial_values_to_member_variables(view, db, container)
38 self._set_view_initial_values()
39
51
55
56
57
58
60 self.name = self.view.get_name()
61 self.category = self.view.get_category()
62 try:
63 self._verify_name()
64 if self.container_exists:
65 self._update_container()
66 else:
67 self._create_container()
68 self.view.close()
69 except ValueError:
70 pass
71
74
75
76
77
79 name_is_invalid = (self.name == "")
80 if name_is_invalid:
81 msg = _("Field '%s' can't be empty.") % _("Name")
82 self.view.display_invalid_name(msg)
83 raise ValueError()
84
88
95
102