本文整理汇总了Python中starflyer.redirect函数的典型用法代码示例。如果您正苦于以下问题:Python redirect函数的具体用法?Python redirect怎么用?Python redirect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了redirect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
def get(self, slug = None):
"""show the complete registration form with registration data, user registration and more"""
regform = self.registration_form
userform = self.user_registration_form
# a list of all ticket class objects
ticketlist = self.barcamp.ticketlist
if self.request.method == "POST":
try:
self.process_post_data()
except ProcessingError, e:
self.log.exception()
self.flash(self._("Unfortunately an error occurred when trying to register you. Please try again or contact the barcamptools administrator."), category="danger")
else:
if self.logged_in:
if self.barcamp.paid_tickets:
self.flash(self._("Your ticket reservations have been processed. Please check your email for information on how to pay for your ticket."), category="success")
else:
self.flash(self._("Your ticket reservation was successful."), category="success")
return redirect(self.url_for(".mytickets", slug = self.barcamp.slug))
else:
self.flash(self._("In order to finish your registration you have to activate your account. Please check your email."), category="success")
return redirect(self.url_for(".index", slug = self.barcamp.slug))
示例2: get
def get(self, slug = None):
"""handle the barcamp registration for multiple events with optional registration form"""
if self.barcamp.workflow != "registration":
return "registration is not open yet"
# check if the user has filled out all the required information on the form already
uid = unicode(self.user._id)
if not self.barcamp.registration_data.has_key(uid) and self.barcamp.registration_form:
# user is not in list and we have a form
return redirect(self.url_for(".registration_form", slug = self.barcamp.slug))
# now check the fields
if self.barcamp.registration_form:
ok = True
data = self.barcamp.registration_data[uid]
for field in self.barcamp.registration_form:
if field['required'] and field['name'] not in data:
ok = False
return redirect(self.url_for(".registration_form", slug = self.barcamp.slug))
# user can register, show the list of events
return self.render(
view = self.barcamp_view,
barcamp = self.barcamp,
title = self.barcamp.name,
has_form_data = self.barcamp.registration_data.has_key(uid),
form_data = self.barcamp.registration_data.get(uid,{}),
**self.barcamp)
示例3: get
def get(self):
"""show the registration form"""
cfg = self.module.config
mod = self.module
form = cfg.registration_form
obj_class = cfg.user_class
form = form(self.request.form, module = self.module)
if self.request.method == 'POST':
if form.validate():
f = form.data
user = mod.register(f, create_pw=False)
if cfg.login_after_registration and not cfg.use_double_opt_in:
user = mod.login(self, force=True, **f)
self.flash(self._("Welcome, %(fullname)s") %user)
url_for_params = cfg.urls.login_success
url = self.url_for(**url_for_params)
return redirect(url)
if cfg.use_double_opt_in:
self.flash(self._(u'To finish the registration process please check your email with instructions on how to activate your account.') %user)
url_for_params = cfg.urls.double_opt_in_pending
else:
self.flash(self._(u'Your user registration has been successful') %user)
url_for_params = cfg.urls.registration_success
url = self.url_for(**url_for_params)
return redirect(url)
return self.render(form = form, use_double_opt_in = cfg.use_double_opt_in)
示例4: post
def post(self, slug=None):
"""only a post without parameters is done to add. Post again to unsubscribe"""
view = self.barcamp_view
username = self.request.form.get("u", None)
if username is not None:
user = self.app.module_map.userbase.get_user_by_username(username)
else:
user = self.user
# now check if we are allowed to to any changes to the user. We are if a) we are that user or b) we are an admin
if not view.is_admin and not user == self.user:
self.flash(self._("You are not allowed to change this."), category="danger")
return redirect(self.url_for(".userlist", slug=self.barcamp.slug))
if unicode(user._id) not in self.barcamp.subscribers:
self.barcamp.subscribe(self.user) # we can only subscribe our own user, thus self.user and not user
self.flash(self._("You are now on the list of people interested in the barcamp"), category="success")
else:
self.barcamp.unsubscribe(user) # we can remove any user if we have the permission (see above for the check)
if user == self.user:
self.flash(
self._("You have been removed from the list of people interested in this barcamp"),
category="danger",
)
else:
self.flash(
self._("%(fullname)s has been removed from the list of people interested in this barcamp") % user,
category="danger",
)
return redirect(self.url_for(".userlist", slug=self.barcamp.slug))
示例5: post
def post(self, slug = None):
"""only a post without parameters is done to remove."""
event = self.barcamp.event
view = self.barcamp_view
# get the username from the form
username = self.request.form.get("u", None)
if username is not None:
user = self.app.module_map.userbase.get_user_by_username(username)
else:
user = self.user
uid = unicode(user._id)
# now check if we are allowed to to any changes to the user. We are if a) we are that user or b) we are an admin
if not view.is_admin and not user==self.user:
self.flash(self._("You are not allowed to change this."), category="danger")
return redirect(self.url_for("barcamp_userlist", slug = self.barcamp.slug))
if uid in event.participants:
event.participants.remove(uid)
if len(event.participants) < self.barcamp.size and len(event.waiting_list)>0:
# somebody from the waiting list can move up
nuid = event.waiting_list[0]
event.waiting_list = event.waiting_list[1:]
event.participants.append(nuid)
# you are now still a subscriber
self.barcamp.subscribe(user)
self.barcamp.put()
if user == self.user:
self.flash(self._("You have been removed from the list of participants."), category="danger")
else:
self.flash(self._("%(fullname)s has been removed from the list of participants.") %user, category="danger")
return redirect(self.url_for("barcamp_userlist", slug = self.barcamp.slug))
示例6: get
def get(self):
"""show the registration form"""
cfg = self.module.config
mod = self.module
form = ActivationEMailForm(self.request.form)
if self.request.method == 'POST':
if form.validate():
f = form.data
user = mod.get_user_by_email(f['email'])
if user is not None:
# send out new activation code and redirect to code sent success screen
if user.active:
self.flash(self._("The user is already active. Please log in.") %user)
url_for_params = cfg.urls.activation_success
url = self.url_for(**url_for_params)
return redirect(url)
mod.send_activation_code(user)
self.flash(self._("A new activation code has been sent out, please check your email") %user)
url_for_params = cfg.urls.activation_code_sent
url = self.url_for(**url_for_params)
return redirect(url)
else:
self.flash(self._("This email address cannot not be found in our user database"), category="danger")
return self.render(form = form)
示例7: wrapper
def wrapper(self, *args, **kwargs):
if self.user is None:
self.flash("Sie haben nicht die erforderlichen Rechte, diese Seite einzusehen", category="danger")
return redirect(self.url_for("index"))
if self.user.has_permission("admin"):
return method(self, *args, **kwargs)
self.flash("Sie haben nicht die erforderlichen Rechte, diese Seite einzusehen", category="danger")
return redirect(self.url_for("index"))
示例8: wrapper
def wrapper(self, *args, **kwargs):
if self.user is None:
self.flash(u"Sie haben keine Berechtigung, diese Seite aufzurufen.", category="error")
return redirect(self.url_for("index"))
elif not self.user.has_permission("admin"):
self.flash(u"Sie haben keine Berechtigung, diese Seite aufzurufen.", category="error")
return redirect(self.url_for("index"))
return method(self, *args, **kwargs)
示例9: delete
def delete(self, slug = None):
uid = self.request.args.get("uid")
if len(self.barcamp.admins)<2:
self.flash(self._(u"you at least need to have one administrator."), category="error")
return redirect(self.url_for("barcamps.permissions", slug = slug))
if uid in self.barcamp.admins:
self.barcamp.remove_admin_by_id(uid)
self.barcamp.save()
self.flash(self._(u"Administrator deleted."))
return redirect(self.url_for("barcamps.permissions", slug = slug))
示例10: delete
def delete(self, slug = None):
uid = self.request.args.get("uid")
if uid == self.barcamp.created_by:
self.flash(u"Dem Ersteller des Barcamps kann das Admin-Recht nicht entzogen werden.", category="error")
return redirect(self.url_for("barcamp_permissions", slug = slug))
if len(self.barcamp.admins)<2:
self.flash(u"Es muss mindestens einen Administrator geben.", category="error")
return redirect(self.url_for("barcamp_permissions", slug = slug))
if uid in self.barcamp.admins:
self.barcamp.remove_admin_by_id(uid)
self.barcamp.save()
self.flash(u"Administrator gelöscht.")
return redirect(self.url_for("barcamp_permissions", slug = slug))
示例11: post
def post(self, slug = None):
"""set the visibility of the barcamp"""
email = self.request.form.get("email")
user = self.app.module_map.userbase.get_user_by_email(email)
if user is None:
self.flash("Ein Benutzer mit dieser E-Mail-Adresse wurde leider nicht gefunden.", category="error")
return redirect(self.url_for("barcamp_permissions", slug = slug))
uid = str(user._id)
if uid not in self.barcamp.admins:
self.barcamp.add_admin(user)
self.barcamp.save()
self.flash(u"%s ist nun ebenfalls ein Admin für dieses Barcamp." %user.fullname)
return redirect(self.url_for("barcamp_permissions", slug = slug))
示例12: get
def get(self):
"""show the login form"""
cfg = self.module.config
mod = self.module
form = cfg.login_form
obj_class = cfg.user_class
langs = [getattr(self, 'LANGUAGE', 'en')]
form = cfg.login_form(self.request.form, handler = self)
if self.request.method == 'POST':
if form.validate():
f = form.data
try:
remember = self.module.config.use_remember and self.request.form.get("remember")
user = mod.login(self, **f)
url_for_params = cfg.urls.login_success
url = self.url_for(**url_for_params)
self.flash(self._("Hello %(fullname)s, you are now logged in.") %user)
return redirect(url)
except PasswordIncorrect, e:
log.warn("login failed: incorrect password", username = e.username)
self.flash(self._("Invalid credentials. You might have mistyped something, please check your spelling."), category="danger")
except UserUnknown, e:
log.warn("login failed: unknown user", username = e.username)
self.flash(self._("Invalid credentials. You might have mistyped something, please check your spelling."), category="danger")
except UserNotActive, e:
if cfg.use_double_opt_in:
log.warn("login failed: user account not yet activated")
self.flash(self._("""Your user account has not been activated. In order to receive a new activation email <a href="%s">click here</a>""")
%self.url_for(".activation_code"), category="warning")
else:
log.warn("login failed: unknown error", user = user)
self.flash(self._("Login failed, please try again."), category="danger")
示例13: get
def get(self):
"""show the password set form"""
cfg = self.module.config
mod = self.module
code = self.request.args.get("code", None)
if self.request.method == 'POST':
code = self.request.form.get("code", "")
else:
code = self.request.args.get("code", None)
if code is not None:
user = mod.get_user_by_activation_code(code)
if user is not None:
user.activate()
mod.login(self, user=user, save = False)
user.save()
self.flash(self._("Your password has been successfully changed"))
url_for_params = cfg.urls.activation_success
url = self.url_for(**url_for_params)
return redirect(url)
else:
url = self.url_for(endpoint=".activation_code")
params = {'url': url, 'code' : code}
self.flash(self._("Your password change has failed" %params), category="danger")
self.flash(cfg.messages.activation_failed %params, category="danger")
return self.render()
示例14: delete
def delete(self, seg_id = None, p_id = None):
"""delete a proposal"""
p = self.config.dbs.proposals.get(p_id)
p.set_workflow("deleted")
p.save()
self.flash(u"Der Vorschlag wurde erfolgreich gelöscht", category="danger")
return redirect(self.url_for('segment_view', seg_id=seg_id))
示例15: post
def post(self, slug = None):
"""render the view"""
barcamp_id = self.barcamp._id
# delete pages
self.config.dbs.pages._remove({'barcamp' : unicode(self.barcamp._id)})
# delete sessions
sessions = self.config.dbs.sessions._remove({'barcamp_id' : str(barcamp_id)})
# delete blog entries
blogs = self.config.dbs.blog._remove({'barcamp' : str(barcamp_id)})
# delete galleries
galleries = self.config.dbs.galleries._remove({'barcamp' : str(barcamp_id)})
# delete participant data
data = self.config.dbs.participant_data._remove({'barcamp_id' : str(barcamp_id)})
# delete tickets
data = self.config.dbs.tickets._remove({'barcamp_id' : str(barcamp_id)})
# delete user favs
data = self.config.dbs.userfavs._remove({'barcamp_id' : str(barcamp_id)})
# delete barcamp
self.barcamp.remove()
self.flash(self._("The barcamp and all it's contents have been deleted!"), category="success")
return redirect(self.url_for("index"))