10 |
10 |
11 # import Zope3 interfaces |
11 # import Zope3 interfaces |
12 |
12 |
13 # import local interfaces |
13 # import local interfaces |
14 from zope.annotation.interfaces import IAnnotations |
14 from zope.annotation.interfaces import IAnnotations |
15 from zope.location.location import locate |
|
16 from ztfy.myams.interfaces import IMyAMSApplication |
15 from ztfy.myams.interfaces import IMyAMSApplication |
17 from ztfy.myams.interfaces.configuration import IMyAMSStaticConfiguration, \ |
16 from ztfy.myams.interfaces.configuration import IMyAMSStaticConfiguration, IMyAMSConfigurationTarget, IMyAMSConfiguration |
18 IMyAMSConfigurationTarget, IMyAMSConfiguration |
|
19 |
17 |
20 # import Zope3 packages |
18 # import Zope3 packages |
21 from zope.component import adapter, queryUtility |
19 from zope.component import adapter, queryUtility |
22 from zope.container.contained import Contained |
20 from zope.container.contained import Contained |
23 from zope.interface import implementer, implements |
21 from zope.interface import implementer, implements |
|
22 from zope.location.location import locate |
24 from zope.schema.fieldproperty import FieldProperty |
23 from zope.schema.fieldproperty import FieldProperty |
25 from ztfy.extfile.blob import BlobImage, BlobFile |
24 from ztfy.extfile.blob import BlobImage, BlobFile |
26 from ztfy.file.property import FileProperty |
25 from ztfy.file.property import FileProperty |
27 |
26 |
28 # import local packages |
27 # import local packages |
|
28 from ztfy.mail.adapter import getPrincipalAddress |
|
29 from ztfy.utils.request import queryRequest |
29 from ztfy.utils.traversing import getParent |
30 from ztfy.utils.traversing import getParent |
30 |
31 |
31 |
32 |
32 class MyAMSStaticConfiguration(object): |
33 class MyAMSStaticConfiguration(object): |
33 """MyAMS static configuration""" |
34 """MyAMS static configuration""" |
34 |
35 |
35 implements(IMyAMSStaticConfiguration) |
36 implements(IMyAMSStaticConfiguration) |
36 |
37 |
37 application_package = 'ztfy.myams' |
38 application_package = 'ztfy.myams' |
38 application_name = u'MyAMS' |
39 application_name = u'MyAMS' |
|
40 version_location = u'menus' |
39 include_top_links = True |
41 include_top_links = True |
40 include_site_search = True |
42 include_site_search = True |
41 include_mobile_search = True |
43 include_mobile_search = True |
42 include_user_activity = True |
44 include_user_activity = True |
43 include_user_shortcuts = True |
45 include_user_shortcuts = True |
66 logo = FileProperty(IMyAMSConfiguration['logo'], klass=BlobImage, img_klass=BlobImage) |
68 logo = FileProperty(IMyAMSConfiguration['logo'], klass=BlobImage, img_klass=BlobImage) |
67 logo_title = FieldProperty(IMyAMSConfiguration['logo_title']) |
69 logo_title = FieldProperty(IMyAMSConfiguration['logo_title']) |
68 custom_css = FileProperty(IMyAMSConfiguration['custom_css'], klass=BlobFile) |
70 custom_css = FileProperty(IMyAMSConfiguration['custom_css'], klass=BlobFile) |
69 custom_js = FileProperty(IMyAMSConfiguration['custom_js'], klass=BlobFile) |
71 custom_js = FileProperty(IMyAMSConfiguration['custom_js'], klass=BlobFile) |
70 google_analytics_key = FieldProperty(IMyAMSConfiguration['google_analytics_key']) |
72 google_analytics_key = FieldProperty(IMyAMSConfiguration['google_analytics_key']) |
|
73 uservoice_api_key = FieldProperty(IMyAMSConfiguration['uservoice_api_key']) |
71 |
74 |
72 @property |
75 @property |
73 def static_configuration(self): |
76 def static_configuration(self): |
74 application = getParent(self, IMyAMSApplication) |
77 application = getParent(self, IMyAMSApplication) |
75 if application is not None: |
78 if application is not None: |
76 return queryUtility(IMyAMSStaticConfiguration, name=application.configuration_name) |
79 return queryUtility(IMyAMSStaticConfiguration, name=application.configuration_name) |
|
80 |
|
81 @property |
|
82 def user_email(self): |
|
83 request = queryRequest() |
|
84 if request is None: |
|
85 return None |
|
86 address = getPrincipalAddress(request.principal) |
|
87 if not address: |
|
88 return None |
|
89 return address[0][1] |
77 |
90 |
78 |
91 |
79 MYAMS_CONFIGURATION_KEY = 'ztfy.myams.configuration' |
92 MYAMS_CONFIGURATION_KEY = 'ztfy.myams.configuration' |
80 |
93 |
81 |
94 |