Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored Contacts listing #1012

Merged
merged 1 commit into from
Aug 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Changelog

**Changed**

- #1012 Refactored Contacts listing
- #1010 Increased max length of Results options to 255 chars (was 40)

**Removed**
Expand Down
64 changes: 30 additions & 34 deletions bika/lims/browser/client/views/contacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
# Copyright 2018 by it's authors.
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.

from collections import OrderedDict

from bika.lims import bikaMessageFactory as _
from bika.lims.browser.bika_listing import BikaListingView
from bika.lims.interfaces import IContacts
from bika.lims.utils import get_link, get_email_link
from bika.lims.vocabularies import CatalogVocabulary
from zope.interface import implements

Expand Down Expand Up @@ -42,57 +45,50 @@ def __init__(self, context, request):
self.title = self.context.translate(_("Contacts"))
self.description = ""

self.columns = {
'getFullname': {'title': _('Full Name'),
'index': 'getFullname'},
'Username': {'title': _('User Name')},
'getEmailAddress': {'title': _('Email Address')},
'getBusinessPhone': {'title': _('Business Phone')},
'getMobilePhone': {'title': _('Mobile Phone')},
}
self.columns = OrderedDict((
("getFullname", {
"title": _("Full Name"),
"index": "getFullname",
"sortable": True, }),
("Username", {
"title": _("User Name"), }),
("getEmailAddress", {
"title": _("Email Address"), }),
("getBusinessPhone", {
"title": _("Business Phone"), }),
("getMobilePhone", {
"title": _("MobilePhone"), }),
))

self.review_states = [
{'id': 'default',
'title': _('Active'),
'contentFilter': {'inactive_state': 'active'},
'transitions': [{'id': 'deactivate'}, ],
'columns': ['getFullname',
'Username',
'getEmailAddress',
'getBusinessPhone',
'getMobilePhone']},
'columns': self.columns.keys()},
{'id': 'inactive',
'title': _('Dormant'),
'contentFilter': {'inactive_state': 'inactive'},
'transitions': [{'id': 'activate'}, ],
'columns': ['getFullname',
'Username',
'getEmailAddress',
'getBusinessPhone',
'getMobilePhone']},
'columns': self.columns.keys()},
{'id': 'all',
'title': _('All'),
'contentFilter': {},
'columns': ['getFullname',
'Username',
'getEmailAddress',
'getBusinessPhone',
'getMobilePhone']},
'columns': self.columns.keys()},
]

def folderitem(self, obj, item, index):
username = obj.getUsername()
item['getFullname'] = obj.getFullname()
item['getEmailAddress'] = obj.getEmailAddress()
url = item.get("url")
email = obj.getEmailAddress()
fullname = obj.getFullname()
item['getFullname'] = fullname
item['getEmailAddress'] = email
item['getBusinessPhone'] = obj.getBusinessPhone()
item['getMobilePhone'] = obj.getMobilePhone()
item['Username'] = username and username or ''
item['replace']['getFullname'] = \
"<a href='%s'>%s</a>" % (
item['url'], item['getFullname'])
if item['getEmailAddress']:
addr = item['getEmailAddress']
item['replace']['getEmailAddress'] = \
"<a href='mailto:%s'>%s</a>" % (addr, addr)
item['Username'] = obj.getUsername() or ""
item['replace']['getFullname'] = get_link(url, fullname)
if email:
item["replace"]['getEmailAddress'] = get_email_link(email)
return item


Expand Down