[MERGE]: survey: fixed a bug in warning message when users exceed maximal number...
authorThibault Delavallée <tde@openerp.com>
Thu, 12 Jan 2012 15:05:15 +0000 (16:05 +0100)
committerThibault Delavallée <tde@openerp.com>
Thu, 12 Jan 2012 15:05:15 +0000 (16:05 +0100)
bzr revid: tde@openerp.com-20120112150515-sxozygi6n4m6hs0f

16 files changed:
addons/auth_openid/__openerp__.py
addons/auth_openid/controllers/main.py
addons/auth_openid/static/src/css/openid.css
addons/auth_openid/static/src/js/auth_openid.js
addons/auth_openid/static/src/xml/auth_openid.xml
addons/survey/wizard/survey_selection.py
addons/web/common/http.py
addons/web/common/session.py
addons/web/controllers/main.py
addons/web/static/src/css/base.css
addons/web/static/src/js/chrome.js
addons/web/static/src/js/core.js
addons/web/static/src/js/view_form.js
addons/web_calendar/static/src/js/calendar.js
debian/control
setup.py [changed mode: 0644->0755]

index 6fa802b..178996b 100644 (file)
@@ -2,7 +2,7 @@
 ##############################################################################
 #
 #    OpenERP, Open Source Management Solution
-#    Copyright (C) 2010-2011 OpenERP s.a. (<http://openerp.com>).
+#    Copyright (C) 2010-2012 OpenERP s.a. (<http://openerp.com>).
 #
 #    This program is free software: you can redistribute it and/or modify
 #    it under the terms of the GNU Affero General Public License as
@@ -38,6 +38,9 @@
     'css': [
         'static/src/css/openid.css',
     ],
+    'qweb': [
+        'static/src/xml/auth_openid.xml',
+    ],
     'external_dependencies': {
         'python' : ['openid'],
     },
index 0c1274b..c95189b 100644 (file)
@@ -2,7 +2,7 @@
 ##############################################################################
 #
 #    OpenERP, Open Source Management Solution
-#    Copyright (C) 2010-2011 OpenERP s.a. (<http://openerp.com>).
+#    Copyright (C) 2010-2012 OpenERP s.a. (<http://openerp.com>).
 #
 #    This program is free software: you can redistribute it and/or modify
 #    it under the terms of the GNU Affero General Public License as
@@ -216,7 +216,7 @@ class OpenIDController(openerpweb.Controller):
 
 
         fragment = '#loginerror' if not user_id else ''
-        return werkzeug.utils.redirect('/web/webclient/home?debug=1'+fragment)
+        return werkzeug.utils.redirect('/'+fragment)
 
     @openerpweb.jsonrequest
     def status(self, req):
index 8763ec3..ab01ffd 100644 (file)
@@ -1,4 +1,9 @@
-input[name='openid_url'] {
+.login .pane {
+    width: 260px;
+    height: 175px;
+}
+
+.login .pane input[name='openid_url'] {
     background: #fff url(../img/login-bg.gif) no-repeat 1px;
     padding-left: 20px;
 }
@@ -8,19 +13,6 @@ input[name='openid_url'] {
     display: none;
 }
 
-.openerp .login .oe_forms .oe_box2 td input[name="db"], .oe_forms .oe_box2 td select[name="db"] {
-    width: 50%;
-    float: left;
-    margin-top: 15px;
-}
-
-.openerp .login .oe_login_right_pane {
-    margin-left: 525px;
-}
-.openerp .login form {
-    width: 475px;
-}
-
 .openid_providers {
     padding: 0;
     list-style: none;
@@ -59,6 +51,6 @@ input[name='openid_url'] {
 .openid_providers a[title="Launchpad"]   { background-image: url(../img/launchpad.png); }
 
 
-tr.auth_choice.selected {
+li.auth_choice.selected {
     display: table-row;
 }
index bc067d8..fd6ec01 100644 (file)
@@ -2,13 +2,14 @@
 openerp.auth_openid = function(instance) {
 
 var QWeb = instance.web.qweb;
-QWeb.add_template('/auth_openid/static/src/xml/auth_openid.xml');
 
 instance.web.Login = instance.web.Login.extend({
     start: function() {
         this._super.apply(this, arguments);
         var self = this;
 
+        this._default_error_message = this.$element.find('.login_error_message').text();
+
         this.$openid_selected_button = $();
         this.$openid_selected_input = $();
         this.$openid_selected_provider = null;
@@ -39,6 +40,8 @@ instance.web.Login = instance.web.Login.extend({
             }
         });
 
+        this._check_fragment();
+
     },
 
 
@@ -48,7 +51,7 @@ instance.web.Login = instance.web.Login.extend({
             self.$openid_selected_button.add(self.$openid_selected_input).removeClass('selected');
             self.$openid_selected_button = self.$element.find(button).addClass('selected');
 
-            var input = _(provider.split(',')).map(function(p) { return 'tr[data-provider="'+p+'"]'; }).join(',');
+            var input = _(provider.split(',')).map(function(p) { return 'li[data-provider="'+p+'"]'; }).join(',');
             self.$openid_selected_input = self.$element.find(input).addClass('selected');
 
             self.$openid_selected_input.find('input:first').focus();
@@ -64,20 +67,20 @@ instance.web.Login = instance.web.Login.extend({
 
     },
 
-    on_login_invalid: function() {
+    _check_fragment: function() {
         var self = this;
         var fragment = jQuery.deparam.fragment();
-        if (fragment.loginerror != undefined) {
+        console.log(fragment);
+        if (fragment.loginerror !== undefined) {
             this.rpc('/auth_openid/login/status', {}, function(result) {
                 if (_.contains(['success', 'failure'], result.status) && result.message) {
-                    self.notification.warn('Invalid OpenID Login', result.message);
+                    self.do_warn('Invalid OpenID Login', result.message);
                 }
                 if (result.status === 'setup_needed' && result.message) {
                     window.location.replace(result.message);
                 }
             });
         }
-        return this._super();
     },
 
     on_submit: function(ev) {
@@ -86,6 +89,7 @@ instance.web.Login = instance.web.Login.extend({
 
         if(!dataurl) {
             // login-password submitted
+            this.reset_error_message();
             this._super(ev);
         } else {
             ev.preventDefault();
@@ -107,13 +111,11 @@ instance.web.Login = instance.web.Login.extend({
         var self = this;
         this.rpc('/auth_openid/login/verify', {'db': db, 'url': openid_url}, function(result) {
             if (result.error) {
-                self.notification.warn(result.title, result.error);
-                self.on_login_invalid();
+                self.do_warn(result.title, result.error);
                 return;
             }
             if (result.session_id) {
-                self.session.session_id = result.session_id;
-                self.session.session_save();
+                self.session.set_cookie('session_id', result.session_id);
             }
             if (result.action === 'post') {
                 document.open();
@@ -128,6 +130,14 @@ instance.web.Login = instance.web.Login.extend({
         });
     },
 
+    do_warn: function(title, msg) {
+        //console.warn(title, msg);
+        this.$element.find('.login_error_message').text(msg).show();
+    },
+
+    reset_error_message: function() {
+        this.$element.find('.login_error_message').text(this._default_error_message);
+    }
 
 });
 
index 6fbab72..3489455 100644 (file)
@@ -3,7 +3,7 @@
 <templates id="template" xml:space="preserve">
 
     <t t-extend="Login">
-        <t t-jquery=".oe_box2 tr:first td:nth-child(2)" t-operation="append">
+        <t t-jquery=".login .pane div#logo" t-operation="after">
             <ul class="openid_providers">
                 <li><a href="#login,password" title="Password" data-url="" id="btn_password">Password</a></li>
                 <li><a href="#google" title="Google" data-url="https://www.google.com/accounts/o8/id">Google</a></li>
             </tr>
         </t>
     </t>
+    <t t-extend="Login">
+        <t t-jquery=".login .pane form ul li:nth-child(4)" t-operation="after">
+            <li>
+                Google Apps Domain
+            </li>
+            <li>
+                <input type="text" name="googleapps" />
+            </li>
+            <li>
+                Username
+            </li>
+            <li>
+                <input type="text" name="launchpad" />
+            </li>
+            <li>
+                OpenID URL
+            </li>
+            <li>
+                <input type="text" name="openid_url" />
+            </li>
+        </t>
+    </t>
 
     <t t-extend="Login">
-        <t t-jquery=".oe_box2 tr:has(input[name!='db'])">
-            //this.addClass('auth_choice');     // XXX for some reason, not all tr tags are HTMLElement's and thus, jQuery decide to not change the class...
-            this.attr('class', 'auth_choice');
+        <t t-jquery=".login .pane form ul li:has(input)">
             this.each(function() {
-                var $i = $(this);
-                $i.attr('data-provider', $i.find('input').attr('name'));
+                var $i = $(this),
+                    dp = $i.find('input').attr('name');
+                $i.add($i.prev()).attr('class', 'auth_choice').attr('data-provider', dp);
             });
         </t>
     </t>
index 7683e85..a1fd05c 100644 (file)
@@ -63,7 +63,7 @@ class survey_name_wiz(osv.osv_memory):
         res = cr.fetchone()[0]
         sur_rec = survey_obj.browse(cr,uid,survey_id,context=context)
         if sur_rec.response_user and res >= sur_rec.response_user:
-            raise osv.except_osv(_('Warning !'),_("You can not give response for this survey more than %s times") % (sur_rec))
+            raise osv.except_osv(_('Warning !'),_("You can not give response for this survey more than %s times") % (sur_rec.response_user))
 
         if sur_rec.max_response_limit and sur_rec.max_response_limit <= sur_rec.tot_start_survey:
             raise osv.except_osv(_('Warning !'),_("You can not give more response. Please contact the author of this survey for further assistance."))
index 0c239de..6e4cbaa 100644 (file)
@@ -10,6 +10,7 @@ import os
 import pprint
 import sys
 import threading
+import time
 import traceback
 import urllib
 import uuid
@@ -331,8 +332,9 @@ def session_context(request, storage_path, session_cookie='sessionid'):
             if (isinstance(value, session.OpenERPSession) 
                 and not value._uid
                 and not value.jsonp_requests
+                and value._creation_time + (60*5) < time.time()  # FIXME do not use a fixed value
             ):
-                _logger.info('remove session %s: %r', key, value.jsonp_requests)
+                _logger.info('remove session %s', key)
                 del request.session[key]
 
         with session_lock:
index ac0489b..ca23a08 100644 (file)
@@ -29,6 +29,7 @@ class OpenERPSession(object):
         round-tripped to the client browser.
     """
     def __init__(self):
+        self._creation_time = time.time()
         self.config = None
         self._db = False
         self._uid = False
index b640587..fd8d85f 100644 (file)
@@ -1257,6 +1257,7 @@ class Binary(openerpweb.Controller):
             attachment_id = Model.create({
                 'name': ufile.filename,
                 'datas': base64.encodestring(ufile.read()),
+                'datas_fname': ufile.filename,
                 'res_model': model,
                 'res_id': int(id)
             }, context)
index 9e5bae8..d4bd7a6 100644 (file)
@@ -437,6 +437,7 @@ label.error {
     position: absolute;
     cursor: pointer;
     border-left: 1px solid #282828;
+    border-bottom: 1px solid #282828;
     width: 21px;
     height: 21px;
     z-index: 10;
index 39ddd0e..7af7292 100644 (file)
@@ -132,7 +132,7 @@ openerp.web.Dialog = openerp.web.Widget.extend(/** @lends openerp.web.Dialog# */
         }
     },
     on_resized: function() {
-        openerp.log("Dialog resized to %d x %d", this.$element.width(), this.$element.height());
+        //openerp.log("Dialog resized to %d x %d", this.$element.width(), this.$element.height());
     },
     stop: function () {
         // Destroy widget
index d5c096d..0584c49 100644 (file)
@@ -695,6 +695,7 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.
                     });
                 })
             ).then(function() {
+                self.on_modules_loaded();
                 self.on_session_valid();
             });
         });
@@ -728,7 +729,6 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.
             var head = document.head || document.getElementsByTagName('head')[0];
             head.appendChild(tag);
         } else {
-            self.on_modules_loaded();
             d.resolve();
         }
         return d;
index 1531f32..43f5923 100644 (file)
@@ -444,15 +444,15 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView#
             } else {
                 var save_deferral;
                 if (!self.datarecord.id) {
-                    console.log("FormView(", self, ") : About to create", values);
+                    //console.log("FormView(", self, ") : About to create", values);
                     save_deferral = self.dataset.create(values).pipe(function(r) {
                         return self.on_created(r, undefined, prepend_on_create);
                     }, null);
                 } else if (_.isEmpty(values)) {
-                    console.log("FormView(", self, ") : Nothing to save");
+                    //console.log("FormView(", self, ") : Nothing to save");
                     save_deferral = $.Deferred().resolve({}).promise();
                 } else {
-                    console.log("FormView(", self, ") : About to save", values);
+                    //console.log("FormView(", self, ") : About to save", values);
                     save_deferral = self.dataset.write(self.datarecord.id, values, {}).pipe(function(r) {
                         return self.on_saved(r);
                     }, null);
@@ -514,7 +514,7 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView#
             if (this.sidebar) {
                 this.sidebar.attachments.do_update();
             }
-            openerp.log("The record has been created with id #" + this.datarecord.id);
+            //openerp.log("The record has been created with id #" + this.datarecord.id);
             this.reload();
             return $.when(_.extend(r, {created: true})).then(success);
         }
index fe5799d..8e03208 100644 (file)
@@ -296,36 +296,25 @@ openerp.web_calendar.CalendarView = openerp.web.View.extend({
         var self = this,
             data = this.get_event_data(event_obj),
             form = self.form_dialog.form,
-            fields_to_fetch = _(form.fields_view.fields).keys(),
-            set_values = [], 
-            fields_names = [];
+            fields_to_fetch = _(form.fields_view.fields).keys();
         this.dataset.index = null;
         self.creating_event_id = event_id;
         this.form_dialog.form.do_show().then(function() {
             form.show_invalid = false;
-            _.each(['date_start', 'date_stop', 'date_delay'], function(field) {
+            _.each(['date_start', 'date_delay', 'date_stop'], function(field) {
                 var field_name = self[field];
                 if (field_name && form.fields[field_name]) {
                     var ffield = form.fields[field_name];
                     ffield.reset();
-                    var result = ffield.set_value(data[field_name]);
-                    set_values.push(result);
-                    fields_names.push(field_name);
-                    $.when(result).then(function() {
+                    $.when(ffield.set_value(data[field_name])).then(function() {
                         ffield.validate();
+                        ffield.dirty = true;
+                        form.do_onchange(ffield);
                     });
                 }
             });
-
-            $.when(set_values).then(function() {
-                _.each(fields_names, function(fn) {
-                    var field = form.fields[fn];
-                    field.dirty = true;
-                    form.do_onchange(field);
-                });
-                form.show_invalid = true;
-                self.form_dialog.open();
-            });
+            form.show_invalid = true;
+            self.form_dialog.open();
         });
     },
     do_save_event: function(event_id, event_obj) {
@@ -362,6 +351,8 @@ openerp.web_calendar.CalendarView = openerp.web.View.extend({
                 event_obj['start_date'].addHours(8);
                 event_obj['end_date'] = new Date(event_obj['start_date']);
                 event_obj['end_date'].addHours(1);
+            } else {
+                event_obj['end_date'].addSeconds(-1);
             }
             this.do_create_event_with_formdialog(event_id, event_obj);
             // return false;
index 8b404a2..ce0d3df 100644 (file)
@@ -35,6 +35,7 @@ Depends:
  python-vobject,
  python-webdav,
  python-werkzeug,
+ python-xlwt,
  python-yaml,
  python-zsi
 Conflicts: tinyerp-server, openerp-server, openerp-web
old mode 100644 (file)
new mode 100755 (executable)
index a239b6f..be9e90b
--- a/setup.py
+++ b/setup.py
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero 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 Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
 
-import os
-import re
-import sys
-from setuptools import setup, find_packages
+import glob, os, re, setuptools, sys
+from os.path import join, isfile
 
-execfile('addons/web/common/release.py')
+# List all data files
+def data():
+    files = []
+    for root, dirnames, filenames in os.walk('openerp'):
+        for filename in filenames:
+            if not re.match(r'.*(\.pyc|\.pyo|\~)$',filename):
+                files.append(os.path.join(root, filename))
+    d = {}
+    for v in files:
+        k=os.path.dirname(v)
+        if k in d:
+            d[k].append(v)
+        else:
+            d[k]=[v]
+    r = d.items()
+    if os.name == 'nt':
+        r.append(("Microsoft.VC90.CRT", glob.glob('C:\Microsoft.VC90.CRT\*.*')))
+    return r
 
-version_dash_incompatible = False
-if 'bdist_rpm' in sys.argv:
-    version_dash_incompatible = True
-try:
-    import py2exe
-    from py2exe_utils import opts
-    version_dash_incompatible = True
-except ImportError:
-    opts = {}
-if version_dash_incompatible:
-    version = version.split('-')[0]
+def gen_manifest():
+    file_list="\n".join(data())
+    open('MANIFEST','w').write(file_list)
 
-FILE_PATTERNS = \
-    r'.+\.(py|cfg|po|pot|mo|txt|rst|gif|png|jpg|ico|mako|html|js|css|htc|swf)$'
-def find_data_files(source, patterns=FILE_PATTERNS):
-    file_matcher = re.compile(patterns, re.I)
-    out = []
-    for base, _, files in os.walk(source):
-        cur_files = []
-        for f in files:
-            if file_matcher.match(f):
-                cur_files.append(os.path.join(base, f))
-        if cur_files:
-            out.append(
-                (base, cur_files))
+if os.name == 'nt':
+    sys.path.append("C:\Microsoft.VC90.CRT")
 
-    return out
+def py2exe_options():
+    if os.name == 'nt':
+        import py2exe
+        return {
+            "console" : [ { "script": "openerp-server", "icon_resources": [(1, join("install","openerp-icon.ico"))], }],
+            'options' : {
+                "py2exe": {
+                    "skip_archive": 1,
+                    "optimize": 2,
+                    "dist_dir": 'dist',
+                    "packages": [ "DAV", "HTMLParser", "PIL", "asynchat", "asyncore", "commands", "dateutil", "decimal", "email", "encodings", "imaplib", "lxml", "lxml._elementpath", "lxml.builder", "lxml.etree", "lxml.objectify", "mako", "openerp", "poplib", "pychart", "pydot", "pyparsing", "reportlab", "select", "simplejson", "smtplib", "uuid", "vatnumber", "vobject", "xml", "xml.dom", "yaml", ],
+                    "excludes" : ["Tkconstants","Tkinter","tcl"],
+                }
+            }
+        }
+    else:
+        return {}
 
-setup(
-    name=name,
-    version=version,
-    description=description,
-    long_description=long_description,
-    author=author,
-    author_email=author_email,
-    url=url,
-    download_url=download_url,
-    license=license,
-    install_requires=[
-        "Babel >= 0.9.6",
-        "simplejson >= 2.0.9",
-        "python-dateutil >= 1.4.1, < 2",
-        "pytz",
-        "werkzeug == 0.7",
-    ],
-    tests_require=[
-        'unittest2',
-        'mock',
-    ],
-    test_suite = 'unittest2.collector',
-    zip_safe=False,
-    packages=find_packages(),
-    classifiers=[
-        'Development Status :: 6 - Production/Stable',
-        'Operating System :: OS Independent',
-        'Programming Language :: Python',
-        'Environment :: Web Environment',
-        'Topic :: Office/Business :: Financial',
-        ],
-    scripts=['openerp-web'],
-    data_files=(find_data_files('addons')
-              + opts.pop('data_files', [])
-    ),
-    **opts
+execfile(join(os.path.dirname(__file__), 'openerp', 'release.py'))
+
+setuptools.setup(
+      name             = 'openerp',
+      version          = version,
+      description      = description,
+      long_description = long_desc,
+      url              = url,
+      author           = author,
+      author_email     = author_email,
+      classifiers      = filter(None, classifiers.split("\n")),
+      license          = license,
+      scripts          = ['openerp-server'],
+      data_files       = data(),
+      packages         = setuptools.find_packages(),
+      #include_package_data = True,
+      install_requires = [
+        # TODO the pychart package we include in openerp corresponds to PyChart 1.37.
+        # It seems there is a single difference, which is a spurious print in generate_docs.py.
+        # It is probably safe to move to PyChart 1.39 (the latest one).
+        # (Let setup.py choose the latest one, and we should check we can remove pychart from
+        # our tree.) http://download.gna.org/pychart/
+        # TODO  'pychart',
+          'babel',
+          'feedparser',
+          'gdata',
+          'lxml',
+          'mako',
+          'psycopg2',
+          'pydot',
+          'python-dateutil < 2',
+          'python-ldap',
+          'python-openid',
+          'pytz',
+          'pywebdav',
+          'pyyaml',
+          'reportlab',
+          'simplejson',
+          'vatnumber',
+          'vobject',
+          'werkzeug',
+          'xlwt',
+          'zsi',
+      ],
+      extras_require = {
+          'SSL' : ['pyopenssl'],
+      },
+      **py2exe_options()
 )
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: