def developer_option(user): di_business_area = ellipsize(user.di_business_area, 40) if user.di_business_area else _(u'N/A') ideas_count = len(user.assignated_di_ideas) label = '%s - %s (%d)' % (di_business_area, user.fullname, ideas_count) option = h.option(label, value=user.uid) if self.current_di: option = option.selected(self.current_di.uid) return option
def developer_option(user): di_business_area = ellipsize( user.di_business_area, 40) if user.di_business_area else _(u'N/A') ideas_count = len(user.assignated_di_ideas) label = '%s - %s (%d)' % (di_business_area, user.fullname, ideas_count) option = h.option(label, value=user.uid) if self.current_di: option = option.selected(self.current_di.uid) return option
def __init__(self, parent, default_challenge_id=None): super(ChallengePage, self).__init__() self.parent = parent event_management._register_listener(parent, self) now = datetime.datetime.now() self.items = [ (challenge.short_title or ellipsize(challenge.title, 35), Challenge(parent, challenge.id)) for challenge in self._challenges if challenge.is_active(now) ] self.items = [(_(u"All challenges"), None)] + self.items self.menu = component.Component(Menu([label for label, challenge in self.items]), model="challenges") self.menu.on_answer(self.select_challenge) self.content = component.Component(None) self.current_challenge = component.Component(None) self.ordered = component.Component(None) self.filtered = component.Component(None) self.excel_exporter = component.Component(None) self.batch_size_changer = component.Component(None) self.idea_counter = component.Component(None) for index, (label, challenge) in enumerate(self.items): if challenge and challenge.challenge_id == default_challenge_id: self.select_challenge(index) break if not self.menu().selected(): # challenge selected fallback to first one or all if len(self.items) > 1: show_challenge = False self.select_challenge(1) else: show_challenge = True self.select_challenge(0)
def render_point_items(self, h, comp, category, points): # configuration of the view reason_title = _(u"Reason") subject_title = _(u"Subject") if category == PointCategory.REMOVE_COMMENT: subject_title = _(u'Deleted comment') elif category == PointCategory.ADD_COMMENT: subject_title = _(u'Added comment') show_reason = any(p.reason for p in points) show_subject = any(p.subject_as_string() for p in points) show_delete = (category in get_manual_point_categories() ) and security.has_permissions('edit_points', self) categories_to_highlight = (PointCategory.PUBLISH_IDEA, PointCategory.PUBLISH_CHALLENGE_FIRST_IDEA, PointCategory.APPROVAL, PointCategory.SELECTED_IDEA) must_highlight = category in categories_to_highlight points_sum = sum([p.nb_points for p in points]) # title with h.div(class_='title ' + ('highlight' if must_highlight else '')): if security.has_permissions('view_points_detail', self): h << h.a(class_="toggle on", onclick='toggleCollapseExpand(this);') h << h.a(class_="toggle off", onclick='toggleCollapseExpand(this);') else: h << h.a(class_="toggle off", style='display:block;') h << h.span(_(category), class_='label') h << _(u': ') h << h.span(_(u'%d point(s)') % points_sum, class_='nb_points') # expandable details points.sort(key=operator.attrgetter('date'), reverse=True) if security.has_permissions('view_points_detail', self): with h.table(class_='items'): with h.thead: with h.colgroup: h << h.col(class_='date') << h.col(class_='points') if show_subject: h << h.col(class_='subject') if show_reason: h.col(class_='reason') if show_delete: h.col(class_='action') with h.tbody: with h.tr: h << h.th(_(u'Date')) << h.th(_(u'Points')) if show_subject: h << h.th(subject_title) if show_reason: h << h.th(reason_title) if show_delete: h << h.th for idx, p in enumerate(points): with h.tr(class_='odd' if idx % 2 == 0 else 'even'): formatted_date = format_datetime(p.date, format='short') h << h.td(formatted_date, class_='date') h << h.td(p.nb_points or '-', class_='nb_points') if show_subject: subj = p.subject_as_string() h << h.td(ellipsize(subj, 60), title=subj) if show_reason: reason = p.reason or '' h << h.td(ellipsize(reason, 50), title=reason, class_='reason') if show_delete: js = 'return yuiConfirm(this.href, "%s", "%s")' % ( _(u'Confirm delete?'), _(u'This point item will be deleted permanently: are you sure?' )) h << h.td( h.a(_(u'Delete'), title=_(u'Delete'), class_='delete', onclick=js).action( lambda id=p.id: self.remove_point(id)))
def render_point_items(self, h, comp, category, points): # configuration of the view reason_title = _(u"Reason") subject_title = _(u"Subject") if category == PointCategory.REMOVE_COMMENT: subject_title = _(u'Deleted comment') elif category == PointCategory.ADD_COMMENT: subject_title = _(u'Added comment') show_reason = any(p.reason for p in points) show_subject = any(p.subject_as_string() for p in points) show_delete = (category in get_manual_point_categories()) and security.has_permissions('edit_points', self) categories_to_highlight = (PointCategory.PUBLISH_IDEA, PointCategory.PUBLISH_CHALLENGE_FIRST_IDEA, PointCategory.APPROVAL, PointCategory.SELECTED_IDEA) must_highlight = category in categories_to_highlight points_sum = sum([p.nb_points for p in points]) # title with h.div(class_='title ' + ('highlight' if must_highlight else '')): if security.has_permissions('view_points_detail', self): h << h.a(class_="toggle on", onclick='toggleCollapseExpand(this);') h << h.a(class_="toggle off", onclick='toggleCollapseExpand(this);') else: h << h.a(class_="toggle off", style='display:block;') h << h.span(_(category), class_='label') h << _(u': ') h << h.span(_(u'%d point(s)') % points_sum, class_='nb_points') # expandable details points.sort(key=operator.attrgetter('date'), reverse=True) if security.has_permissions('view_points_detail', self): with h.table(class_='items'): with h.thead: with h.colgroup: h << h.col(class_='date') << h.col(class_='points') if show_subject: h << h.col(class_='subject') if show_reason: h.col(class_='reason') if show_delete: h.col(class_='action') with h.tbody: with h.tr: h << h.th(_(u'Date')) << h.th(_(u'Points')) if show_subject: h << h.th(subject_title) if show_reason: h << h.th(reason_title) if show_delete: h << h.th for idx, p in enumerate(points): with h.tr(class_='odd' if idx % 2 == 0 else 'even'): formatted_date = format_datetime(p.date, format='short') h << h.td(formatted_date, class_='date') h << h.td(p.nb_points or '-', class_='nb_points') if show_subject: subj = p.subject_as_string() h << h.td(ellipsize(subj, 60), title=subj) if show_reason: reason = p.reason or '' h << h.td(ellipsize(reason, 50), title=reason, class_='reason') if show_delete: js = 'return yuiConfirm(this.href, "%s", "%s")' % (_(u'Confirm delete?'), _(u'This point item will be deleted permanently: are you sure?')) h << h.td(h.a(_(u'Delete'), title=_(u'Delete'), class_='delete', onclick=js).action(lambda id=p.id: self.remove_point(id)))