class UserImportForm(formencode.Schema): allow_extra_fields = True users_csv = forms.UsersCSV() email_subject = formencode.validators.String( not_empty=True, messages={ 'empty': L_('Please insert a subject for the ' 'mail we will send to the users.') }) email_template = forms.ContainsEMailPlaceholders( not_empty=True, messages={ 'empty': L_('Please insert a template for the ' 'mail we will send to the users.') })
def settings_menu(instance, current): return Menu.create(instance, current, OrderedDict([ ('general', (L_(u'General'), True, 'settings')), ('appearance', (L_('Appearance'),)), ('contents', (L_('Contents'),)), ('voting', (L_('Votings'),)), ('badges', (L_('Badges'),)), ('massmessage', (L_('Mass message service'), can.message.create(instance))), ('members_import', (_('Members import'), (h.has_permission('global.admin') or can.instance.authenticated_edit(instance)))) ]))
def settings_menu(cls, instance, current): class Menu(list): '''Subclass so we can attach attributes''' def url_for(self, value): current = [i for i in self if i['name'] == value] if not current: return ValueError('No Menu item named "%s"' % value) else: return current[0]['url'] def setting(name, label, allowed=True): return { 'name': name, 'url': settings_url(instance, name), 'label': label, 'allowed': allowed } settings = Menu( [{ 'name': 'general', 'url': h.instance.url(instance, member='settings'), 'label': L_('General') }, setting('appearance', L_('Appearance')), setting('contents', L_('Contents')), setting('voting', L_('Votings')), setting('badges', L_('Badges')), setting('members_import', L_('Members import'), allowed=(h.has_permission('global.admin') or can.instance.authenticated_edit(instance)))]) if current not in [i['name'] for i in settings]: raise ValueError('current ("%s") is no menu item' % current) for item in settings: item['class'] = '' if item.get('allowed') is None: item['allowed'] = True if current == item['name']: item['active'] = True item['class'] = 'active' settings.current = item return settings
self.by_old[option.old] = option def set_pager(self, pager): self.pager = pager def render(self): return render_def(self.template, self.mako_def, sorts=self) def grouped_options(self): return [(group, self.by_group[group]) for group in self.groups] def __len__(self): return len(self.by_value.keys()) OLDEST = SortOption('+create_time', L_("Oldest")) NEWEST = SortOption('-create_time', L_("Newest")) NEWEST_COMMENT = SortOption('-order.newestcomment', L_("Newest Comment")) ACTIVITY = SortOption('-activity', L_("Activity")) ALPHA = SortOption('order.title', L_("Alphabetically")) PROPOSAL_SUPPORT = SortOption('-order.proposal.support', L_("Most Support"), description=L_('Yays - nays')) PROPOSAL_VOTES = SortOption('-order.proposal.votes', L_("Most Votes"), description=L_('Yays + nays')) PROPOSAL_YES_VOTES = SortOption('-order.proposal.yesvotes', L_("Most Ayes")) PROPOSAL_NO_VOTES = SortOption('-order.proposal.novotes', L_("Most Nays")) PROPOSAL_MIXED = SortOption('-order.proposal.mixed', L_('Mixed'), description=L_('Age and Support'))
from collections import OrderedDict from pylons.i18n import lazy_ugettext as L_ from pylons import tmpl_context as c from adhocracy.lib import helpers as h from adhocracy import model INSTANCE_UPDATED_MSG = L_('The changes were saved.') NO_UPDATE_REQUIRED = L_('No update required.') def error_formatter(error): return '<p class="help-block">%s</p>' % error def update_attributes(entity, form_result, attributes): ''' Update the given *attributes* on the *entity* object with the values in *form_result* and returns if an attribute was updated. *entity* (:class:`adhocracy.model.Instance`) The Instance to update. *form_result* (dict) A dict, usually the result of a formencode validation. *attributes* (`list` of `str`) The attributes to update. Returns: `True` if one of the *attributes* was updated, `False`
def test_lazystring(self): from pylons.i18n import lazy_ugettext as L_ c = SignedValueConverter(b'shh!') c.encode({u'str': L_(u'Date')})
] S_MESSAGE = [ 't_message_send', 't_massmessage_send', 'n_message_receive', ] S_CONTRIBUTION = S_PROPOSAL + S_AMENDMENT + S_COMMENT + S_PAGE TYPE_MAPPINGS = dict([(v.code, v) for v in locals().values() if isinstance(v, NotificationType)]) TYPES = TYPE_MAPPINGS.values() TOPIC_TYPES = { "t_user_create": L_('User'), "t_user_edit": L_('User'), "t_user_admin_edit": L_('User'), "t_instance_create": L_('Instance'), "t_instance_edit": L_('Instance'), "t_instance_delete": L_('Instance'), "t_instance_join": L_('Instance'), "t_instance_leave": L_('Instance'), "t_instance_force_leave": L_('Instance'), "t_instance_membership_update": L_('Membership'), "t_proposal_create": L_('Proposal'), "t_proposal_edit": L_('Proposal'), "t_proposal_badge": L_('Proposal'), "t_proposal_state_draft": L_('Proposal'), "t_proposal_state_voting": L_('Proposal'), "t_proposal_delete": L_('Proposal'),