Merge lp:~jfb-tempo-consulting/unifield-web/US-7088 into lp:unifield-web

Proposed by jftempo
Status: Merged
Merged at revision: 4996
Proposed branch: lp:~jfb-tempo-consulting/unifield-web/US-7088
Merge into: lp:unifield-web
Diff against target: 319 lines (+190/-8)
7 files modified
addons/openerp/controllers/root.py (+24/-7)
addons/openerp/controllers/templates/index.mako (+82/-1)
addons/openerp/po/messages/fr.po (+20/-0)
addons/openerp/static/css/menu.css (+49/-0)
addons/openerp/widgets/listgrid.py (+11/-0)
addons/openerp/widgets/templates/listgrid/url.mako (+3/-0)
openobject/static/css/jquery.fancybox-1.3.1.css (+1/-0)
To merge this branch: bzr merge lp:~jfb-tempo-consulting/unifield-web/US-7088
Reviewer Review Type Date Requested Status
UniField Dev Team Pending
Review via email: mp+388059@code.launchpad.net
To post a comment you must log in.
4998. By jftempo

Survey align buttons

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/openerp/controllers/root.py'
2--- addons/openerp/controllers/root.py 2018-04-25 09:45:33 +0000
3+++ addons/openerp/controllers/root.py 2020-08-06 16:14:57 +0000
4@@ -26,7 +26,7 @@
5
6 from openobject.tools import url, expose, redirect
7 from openobject.tools.ast import literal_eval
8-
9+import json
10 _MAXIMUM_NUMBER_WELCOME_MESSAGES = 3
11
12 def _cp_on_error():
13@@ -53,7 +53,13 @@
14 if read_result['action_id']:
15 next = '/openerp/home'
16
17- return self.menu(next=next)
18+ if rpc.session.has_logged:
19+ rpc.session.has_logged = False
20+ from_login = True
21+ else:
22+ from_login = False
23+
24+ return self.menu(next=next, from_login=from_login)
25
26 @expose()
27 def home(self):
28@@ -93,7 +99,7 @@
29 """ % (url("/openerp/static/images/loading.gif"))
30
31 @expose(template="/openerp/controllers/templates/index.mako")
32- def menu(self, active=None, next=None):
33+ def menu(self, active=None, next=None, from_login=False):
34 from openerp.widgets import tree_view
35 if next == '/openerp/pref/update_password':
36 # in case the password must be changed, do not do others operations
37@@ -168,10 +174,17 @@
38 widgets=None
39 display_shortcut = False
40
41-
42-
43+ main_survey = False
44+ other_surveys = []
45+ if from_login:
46+ surveys = rpc.RPCProxy('sync_client.survey').get_surveys()
47+ if surveys:
48+ main_survey = surveys[0]
49+ if len(surveys) > 1:
50+ other_surveys = surveys[1:]
51 return dict(parents=parents, tools=tools, load_content=(next and next or ''),
52- welcome_messages=rpc.RPCProxy('publisher_warranty.contract').get_last_user_messages(_MAXIMUM_NUMBER_WELCOME_MESSAGES),
53+ survey=main_survey,
54+ other_surveys=json.dumps(other_surveys),
55 show_close_btn=rpc.session.uid == 1,
56 widgets=widgets,
57 display_shortcut=display_shortcut)
58@@ -181,6 +194,7 @@
59 target = kw.get('target') or '/'
60 if target.startswith('/openerp/do_login'):
61 target = '/'
62+ rpc.session.has_logged = True
63 raise redirect(target)
64
65 @expose(allow_json=True)
66@@ -257,5 +271,8 @@
67 error = e
68 return dict(error=error)
69
70-
71+ @expose(allow_json=True)
72+ def survey_answer(self, answer, survey_id, stat_id):
73+ rpc.RPCProxy('sync_client.survey.user').save_answer(answer, survey_id, stat_id)
74+ return True
75 # vim: ts=4 sts=4 sw=4 si et
76
77=== modified file 'addons/openerp/controllers/templates/index.mako'
78--- addons/openerp/controllers/templates/index.mako 2017-09-20 15:17:48 +0000
79+++ addons/openerp/controllers/templates/index.mako 2020-08-06 16:14:57 +0000
80@@ -170,12 +170,13 @@
81 </td>
82 </tr>
83 % endif
84+ <% user_locale = cp.locale().language %>
85 <tr>
86 <td id="footer_section" colspan="4">
87 <div class="footer-a">
88 <p class="one">
89 <span>${rpc.session.protocol}://${_("%(user)s", user=rpc.session.loginname)}@${rpc.session.host}:${rpc.session.port}</span>
90- <span>${cp.locale()}</span>
91+ <span>${user_locale}</span>
92 </p>
93 <p class="powered">${_("Powered by %(openerp)s ",
94 openerp="""<a target="_blank" href="http://www.openerp.com/">openerp.com</a>""")|n}</p>
95@@ -184,5 +185,85 @@
96 </tr>
97 </table>
98 </div>
99+
100+
101+ % if survey:
102+ <div id="survey">
103+ <div id="survey_title">${_('We welcome your feedback.')}</div>
104+ <div>${_('Help us improve your experience by taking our short survey.')}</div>
105+ <div id="survey_name">
106+ % if user_locale == 'fr' and survey.get('name_fr'):
107+ ${survey.get('name_fr')}
108+ % else:
109+ ${survey.get('name')}
110+ % endif
111+ </div>
112+ <div class="row">
113+ <div class="column"><div class="survey_button" onclick="click_answer('goto')">${_('Go to survey')}</div></div>
114+ <div class="column"><div class="survey_button" onclick="click_answer('later')">${_('Answer Later')}</div></div>
115+ <div class="column" id="button_never"
116+ % if survey['nb_displayed'] < 3:
117+ style="display: none"
118+ % endif
119+ ><div class="survey_button" onclick="click_answer('never')">${_('Do not ask me again')}</div></div>
120+ </div>
121+ </div>
122+ <script type="text/javascript">
123+ % if user_locale == 'fr' and survey.get('url_fr'):
124+ var survey_url = "${survey.get('url_fr')}";
125+ % else:
126+ var survey_url = "${survey.get('url_en')}";
127+ % endif
128+ var survey_stat_id = ${survey['stat_id']};
129+ var survey_id = ${survey['id']};
130+ var survey_index = 0;
131+
132+ jQuery('#survey').fancybox({'modal': true, 'height': 250, 'width': 700, 'scrolling': 'no', 'autoDimensions': false, 'autoScale': false});
133+
134+ jQuery(document).ready(function() {
135+ jQuery('#survey').trigger('click');
136+ jQuery('#survey').show();
137+ jQuery('#survey').unbind('click.fb');
138+ })
139+
140+
141+ function click_answer(answer) {
142+ if (answer == 'goto') {
143+ window.open(survey_url,'_blank');
144+ }
145+ jQuery.post('/openerp/survey_answer', {'answer': answer, 'survey_id': survey_id, 'stat_id': survey_stat_id});
146+ next_survey = false;
147+ % if len(other_surveys):
148+ var other_surveys = ${other_surveys|n};
149+ if (other_surveys.length > survey_index) {
150+ jQuery('#survey').hide();
151+ next_survey = other_surveys[survey_index];
152+ % if user_locale == 'fr':
153+ survey_url = next_survey.url_fr||next_survey.url_en;
154+ survey_name = next_survey.name_fr||next_survey.name;
155+ % else:
156+ survey_url = next_survey.url_en;
157+ survey_name = next_survey.name;
158+ % endif
159+ survey_stat_id = next_survey.stat_id;
160+ survey_id = next_survey.id;
161+ $('#survey_name').html(survey_name);
162+ if (next_survey.nb_displayed > 2) {
163+ $('#button_never').show();
164+ } else {
165+ $('#button_never').hide();
166+ }
167+ survey_index += 1;
168+ setTimeout(function(){jQuery('#survey').show()}, 450);
169+ }
170+ % endif
171+
172+ if (!next_survey) {
173+ jQuery('#survey').hide();
174+ jQuery.fancybox.close();
175+ }
176+ }
177+ </script>
178+ % endif
179 </%def>
180
181
182=== modified file 'addons/openerp/po/messages/fr.po'
183--- addons/openerp/po/messages/fr.po 2019-10-09 16:15:16 +0000
184+++ addons/openerp/po/messages/fr.po 2020-08-06 16:14:57 +0000
185@@ -1830,3 +1830,23 @@
186 msgid "In Progress"
187 msgstr "En cours"
188
189+#: controllers/templates/preferences/index.mako:191
190+msgid "We welcome your feedback."
191+msgstr "Nous apprécions vos remarques"
192+
193+#: controllers/templates/preferences/index.mako:191
194+msgid "Help us improve your experience by taking our short survey."
195+msgstr "Aidez-nous à améliorer votre expérience en répondant à notre court sondage."
196+
197+#: controllers/templates/preferences/index.mako:201
198+msgid "Go to survey"
199+msgstr "Répondre au sondage"
200+
201+#: controllers/templates/preferences/index.mako:202
202+msgid "Answer Later"
203+msgstr "Plus tard"
204+
205+#: controllers/templates/preferences/index.mako:207
206+msgid "Do not ask me again"
207+msgstr "Ne plus demander"
208+
209
210=== modified file 'addons/openerp/static/css/menu.css'
211--- addons/openerp/static/css/menu.css 2018-05-28 13:16:01 +0000
212+++ addons/openerp/static/css/menu.css 2020-08-06 16:14:57 +0000
213@@ -138,3 +138,52 @@
214 color: #C0C0C0;
215 }
216
217+#survey {
218+ background-color: #5c5cff;
219+ color: #ffffff;
220+ font-size:20px;
221+ text-align: center;
222+ height: 250px;
223+ display: none;
224+}
225+
226+#survey_title {
227+ font-size:35px;
228+ padding-top: 10px;
229+ margin-bottom: 35px;
230+}
231+
232+#survey .column {
233+ display: inline-block;
234+ width: 32%;
235+ text-align: center;
236+}
237+
238+#survey .survey_button {
239+ text-align: center;
240+ background-color: white;
241+ color: #5c5cff;
242+ margin: 5px;
243+ cursor: pointer;
244+ border-radius: 3px;
245+}
246+
247+#survey .survey_button:hover {
248+ background-color: #00A3FF;
249+ color: white;
250+}
251+
252+#survey .row {
253+ padding-top:25px;
254+}
255+/* Clear floats after the columns */
256+#survey .row:after {
257+ content: "";
258+ display: table;
259+ clear: both;
260+}
261+
262+#survey_name {
263+ font-weight: bold;
264+ margin-top: 5px;
265+}
266
267=== modified file 'addons/openerp/widgets/listgrid.py'
268--- addons/openerp/widgets/listgrid.py 2020-04-01 10:02:24 +0000
269+++ addons/openerp/widgets/listgrid.py 2020-08-06 16:14:57 +0000
270@@ -661,6 +661,14 @@
271 class M2M(Char):
272
273 def get_text(self):
274+ if self.truncate:
275+ if not self.value:
276+ return ''
277+ max_length = int(self.truncate)
278+ value_string = ', '.join([x[1] for x in rpc.RPCProxy(self.attrs['relation']).name_get(self.value, rpc.session.context)])
279+ if len(value_string) > max_length:
280+ value_string = '%s...' % value_string[:max_length-3]
281+ return value_string
282 return "%d" % len(self.value)
283
284 class Selection(Char):
285@@ -898,6 +906,8 @@
286 def update_params(self, params):
287 super(Hidden, self).update_params(params)
288
289+class URL(Char):
290+ template = "openerp/widgets/templates/listgrid/url.mako"
291
292 CELLTYPES = {
293 'char':Char,
294@@ -917,4 +927,5 @@
295 'separator': Separator,
296 'human_size': HumanSize,
297 'html_text': HtmlText,
298+ 'url': URL,
299 }
300
301=== added file 'addons/openerp/widgets/templates/listgrid/url.mako'
302--- addons/openerp/widgets/templates/listgrid/url.mako 1970-01-01 00:00:00 +0000
303+++ addons/openerp/widgets/templates/listgrid/url.mako 2020-08-06 16:14:57 +0000
304@@ -0,0 +1,3 @@
305+% if text:
306+<a href="${text}" target="_blank"><img src="/openerp/static/images/icons/gtk-jump-to-ltr.png" title="${text}" /></a>
307+% endif
308
309=== modified file 'openobject/static/css/jquery.fancybox-1.3.1.css'
310--- openobject/static/css/jquery.fancybox-1.3.1.css 2010-08-30 10:24:02 +0000
311+++ openobject/static/css/jquery.fancybox-1.3.1.css 2020-08-06 16:14:57 +0000
312@@ -114,6 +114,7 @@
313 background-position: -40px 0;
314 cursor: pointer;
315 z-index: 1103;
316+ display: none;
317 }
318
319 #fancybox_error {

Subscribers

People subscribed via source and target branches