-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathfrmCreateSource.py
More file actions
75 lines (61 loc) · 3.08 KB
/
Copy pathfrmCreateSource.py
File metadata and controls
75 lines (61 loc) · 3.08 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
"""Subclass of clsSource, which is generated by wxFormBuilder."""
import wx
from odmtools.view.clsCreateSource import clsSource
from odmtools.odmdata import Source
# Implementing clsSource
class frmCreateSource(clsSource):
def __init__(self, parent, service_man, prev_src):
clsSource.__init__(self, parent)
self.service_man = service_man
self.prev = prev_src
self.source = None
self.series_service = self.service_man.get_series_service()
self.populate_meta()
def populate_meta(self):
self.meta_list = {}
metas = self.series_service.get_iso_metadata()
if metas is not None:
self.meta_list = {(x.title, x.id) for x in metas}
# {(key, value) for (key, value) in zip(key_list, value_list)}
self.meta_list["None"] = 0
self.chMeta.AppendItems(self.meta_list.keys())
self.chMeta.SetSelection(0)
def getSource(self):
return self.source
# Handlers for dlgCreateSource events.
def onOkClick(self, event):
self.source = self.createSource()
if self.all_fields_full():
self.EndModal(wx.ID_OK)
else:
wx.MessageDialog(None, "All required source fields must be completed.", " ", wx.OK).ShowModal()
def all_fields_full(self):
return (self.txtOrg.GetValue() != '') and \
(self.txtDescrip.GetValue() != '') and \
(self.txtName.GetValue() != '') and \
(self.txtPhone.GetValue() != '') and \
(self.txtEmail.GetValue() != '') and \
(self.txtAddress.GetValue() != '') and \
(self.txtCity.GetValue() != '') and \
(self.txtState.GetValue() != '') and \
(self.txtZip.GetValue() != '') and \
(self.txtCitation.GetValue() != '')
def createSource(self):
s = Source()
s.organization = self.txtOrg.GetValue() if self.txtOrg.GetValue() != u'' else None
s.description = self.txtDescrip.GetValue() if self.txtDescrip.GetValue() != u'' else None
s.link = self.txtLink.GetValue() if self.txtLink.GetValue() != u'' else None
s.contact_name = self.txtName.GetValue() if self.txtName.GetValue() != u'' else None
s.phone = self.txtPhone.GetValue() if self.txtPhone.GetValue() != u'' else None
s.email = self.txtEmail.GetValue() if self.txtEmail.GetValue() != u'' else None
s.address = self.txtAddress.GetValue() if self.txtAddress.GetValue() != u'' else None
s.city = self.txtCity.GetValue() if self.txtCity.GetValue() != u'' else None
s.state = self.txtState.GetValue() if self.txtState.GetValue() != u'' else None
s.zip_code = self.txtZip.GetValue() if self.txtZip.GetValue() != u'' else None
s.citation = self.txtCitation.GetValue() if self.txtCitation.GetValue() != u'' else None
s.iso_metadata_id = self.meta_list[self.chMeta.GetItems()[self.chMeta.GetSelection()]]
# s.iso_metadata_id = 0
return s
def onCancelClick(self, event):
# TODO: Implement onCancelClick
self.EndModal(wx.ID_CANCEL)