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)
def _process(self): query = (Category.query .filter(Category.id.in_(c.id for c in self.user.favorite_categories)) .options(undefer('chain_titles'))) categories = sorted([(cat, truncate_path(cat.chain_titles[:-1], chars=50)) for cat in query], key=lambda c: (c[0].title, c[1])) return WPUser.render_template('favorites.html', 'favorites', user=self.user, favorite_categories=categories)
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.lang = self.user.settings.get('lang') 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', 'preferences', user=self.user, form=form)
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)
def _process(self): form = UserEmailsForm() if form.validate_on_submit(): self._send_confirmation(form.email.data) flash(_("We have sent an email to {email}. Please click the link in that email within 24 hours to " "confirm your new email address.").format(email=form.email.data), 'success') return redirect(url_for('.user_emails')) return WPUser.render_template('emails.html', 'emails', user=self.user, form=form)
def _process(self): form = UserDetailsForm(obj=FormDefaults(self.user, skip_attrs={'title'}, title=self.user._title), synced_fields=self.user.synced_fields, synced_values=self.user.synced_values) if form.validate_on_submit(): self.user.synced_fields = form.synced_fields form.populate_obj(self.user, skip=self.user.synced_fields) self.user.synchronize_data(refresh=True) flash(_('Your personal data was successfully updated.'), 'success') return redirect(url_for('.user_profile')) return WPUser.render_template('personal_data.html', 'personal_data', user=self.user, form=form)
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.auth_providers.iteritems()} return WPUser.render_template('accounts.html', form=form, user=self.user, provider_titles=provider_titles)
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)
def _process(self): form = UserDetailsForm(obj=FormDefaults(self.user, skip_attrs={'title'}, title=self.user._title), synced_fields=self.user.synced_fields, synced_values=self.user.synced_values) if form.validate_on_submit(): self.user.synced_fields = form.synced_fields form.populate_obj(self.user, skip=self.user.synced_fields) self.user.synchronize_data(refresh=True) flash(_('Your personal data was successfully updated.'), 'success') return redirect(url_for('.user_profile')) from_dt = now_utc(False) - relativedelta(years=100, weeks=1, hour=0, minute=0, second=0) linked_events = [event for event, roles in get_linked_events(self.user, from_dt, 10).iteritems()] return WPUser.render_template('contributions.html', 'contributions', user=self.user, form=form, now_utc=now_utc(False), linked_events=linked_events, gua = get_user_abstracts)
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)
def _process(self): return WPUser.render_template('favorites.html', user=self.user)
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)