diff --git a/auquotidien/modules/myspace.py b/auquotidien/modules/myspace.py index 948cfca..657067f 100644 --- a/auquotidien/modules/myspace.py +++ b/auquotidien/modules/myspace.py @@ -50,14 +50,7 @@ class MyInvoicesDirectory(Directory): invoices = [] invoices.extend(Invoice.get_with_indexed_value( str('user_id'), str(user.id))) - - def cmp_invoice(a, b): - t = cmp(a.regie_id, b.regie_id) - if t != 0: - return t - return -cmp(a.date, b.date) - - invoices.sort(cmp_invoice) + invoices.sort(key=lambda x: (x.regie_id, -x.date)) last_regie_id = None unpaid = False @@ -127,7 +120,7 @@ class JsonDirectory(Directory): for formdef in formdefs: user_forms.extend(formdef.data_class().get_with_indexed_value( 'user_id', self.user.id)) - user_forms.sort(lambda x,y: cmp(x.receipt_time, y.receipt_time)) + user_forms.sort(key=lambda x: x.receipt_time) get_response().set_content_type('application/json') @@ -193,7 +186,7 @@ class MyspaceDirectory(wcs.myspace.MyspaceDirectory): for formdef in formdefs: user_forms.extend(formdef.data_class().get_with_indexed_value( 'user_id', user.id)) - user_forms.sort(lambda x,y: cmp(x.receipt_time, y.receipt_time)) + user_forms.sort(key=lambda x: x.receipt_time) profile_links = [] if not get_cfg('sp', {}).get('idp-manage-user-attributes', False): diff --git a/auquotidien/modules/root.py b/auquotidien/modules/root.py index a823274..d2fc06b 100644 --- a/auquotidien/modules/root.py +++ b/auquotidien/modules/root.py @@ -19,6 +19,7 @@ except ImportError: import wcs import wcs.root from wcs import qommon +from wcs.forms.root import RootDirectory as FormsRootDirectory from wcs.qommon import get_cfg, get_logger from wcs.qommon import template from wcs.qommon import errors @@ -70,70 +71,6 @@ Category.get_limit = category_get_limit Category.TEXT_ATTRIBUTES = ['name', 'url_name', 'description', 'homepage_position'] Category.INT_ATTRIBUTES = ['position', 'limit'] - -class FormsRootDirectory(wcs.forms.root.RootDirectory): - - def _q_index(self, *args): - get_response().filter['is_index'] = True - return wcs.forms.root.RootDirectory._q_index(self, *args) - - def user_forms(self, user_forms): - r = TemplateIO(html=True) - base_url = get_publisher().get_root_url() - - draft = [x for x in user_forms if x.is_draft() and not x.formdef.is_disabled()] - if draft: - r += htmltext('

%s

') % _('My Current Drafts') - r += htmltext('') - - forms_by_status_name = {} - for f in user_forms: - if f.is_draft(): - continue - status = f.get_visible_status() - if status: - status_name = status.name - else: - status_name = None - if status_name in forms_by_status_name: - forms_by_status_name[status_name].append(f) - else: - forms_by_status_name[status_name] = [f] - for status_name in forms_by_status_name: - if status_name: - r += htmltext('

%s

') % _('My forms with status "%s"') % status_name - else: - r += htmltext('

%s

') % _('My forms with an unknown status') % status_name - r += htmltext('') - return r.getvalue() - - OldRegisterDirectory = wcs.root.RegisterDirectory class AlternateRegisterDirectory(OldRegisterDirectory): diff --git a/tests/test_user_pages.py b/tests/test_user_pages.py index 65b0711..8ff9ad8 100644 --- a/tests/test_user_pages.py +++ b/tests/test_user_pages.py @@ -94,13 +94,14 @@ def test_myspace_with_user_forms(): app = login(get_app(pub), username='user', password='user') resp = app.get('/myspace/') - assert 'Status1' in resp - assert '