本文整理汇总了Python中indico.modules.users.views.WPUser类的典型用法代码示例。如果您正苦于以下问题:Python WPUser类的具体用法?Python WPUser怎么用?Python WPUser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WPUser类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _process
def _process(self):
self.user.settings.set('suggest_categories', True)
tz = session.tzinfo
hours, minutes = timedelta_split(tz.utcoffset(datetime.now()))[:2]
categories = get_related_categories(self.user)
categories_events = []
if categories:
category_ids = {c['categ'].id for c in categories.itervalues()}
today = now_utc(False).astimezone(tz).date()
query = (Event.query
.filter(~Event.is_deleted,
Event.category_chain_overlaps(category_ids),
Event.start_dt.astimezone(session.tzinfo) >= today)
.options(joinedload('category').load_only('id', 'title'),
joinedload('series'),
subqueryload('acl_entries'),
load_only('id', 'category_id', 'start_dt', 'end_dt', 'title', 'access_key',
'protection_mode', 'series_id', 'series_pos', 'series_count'))
.order_by(Event.start_dt, Event.id))
categories_events = get_n_matching(query, 10, lambda x: x.can_access(self.user))
from_dt = now_utc(False) - relativedelta(weeks=1, hour=0, minute=0, second=0)
linked_events = [(event, {'management': bool(roles & self.management_roles),
'reviewing': bool(roles & self.reviewer_roles),
'attendance': bool(roles & self.attendance_roles)})
for event, roles in get_linked_events(self.user, from_dt, 10).iteritems()]
return WPUser.render_template('dashboard.html', 'dashboard',
offset='{:+03d}:{:02d}'.format(hours, minutes), user=self.user,
categories=categories,
categories_events=categories_events,
suggested_categories=get_suggested_categories(self.user),
linked_events=linked_events)
示例2: _process
def _process(self):
form = self._create_form()
if form.validate_on_submit():
if isinstance(form, AddLocalIdentityForm):
self._handle_add_local_account(form)
elif isinstance(form, EditLocalIdentityForm):
self._handle_edit_local_account(form)
return redirect(url_for('auth.accounts'))
provider_titles = {name: provider.title for name, provider in multipass.identity_providers.iteritems()}
return WPUser.render_template('accounts.html', form=form, user=self.user, provider_titles=provider_titles)
示例3: _process
def _process(self):
extra_preferences = [pref(self.user) for pref in values_from_signal(signals.users.preferences.send(self.user))]
form_class = UserPreferencesForm
defaults = FormDefaults(**self.user.settings.get_all(self.user))
for pref in extra_preferences:
form_class = pref.extend_form(form_class)
pref.extend_defaults(defaults)
form = form_class(obj=defaults)
if form.validate_on_submit():
data = form.data
for pref in extra_preferences:
pref.process_form_data(data)
self.user.settings.set_multi(data)
session.timezone = (self.user.settings.get('timezone') if self.user.settings.get('force_timezone')
else 'LOCAL')
flash(_('Preferences saved'), 'success')
return redirect(url_for('.user_preferences'))
return WPUser.render_template('preferences.html', user=self.user, form=form)
示例4: _process
def _process(self):
categories = sorted([(cat, truncate_path(cat.getCategoryPathTitles()[:-1], chars=50))
for cat in self.user.favorite_categories], key=lambda c: (c[0].name, c[1]))
return WPUser.render_template('favorites.html', user=self.user, favorite_categories=categories)