• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python starflyer.redirect函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中starflyer.redirect函数的典型用法代码示例。如果您正苦于以下问题:Python redirect函数的具体用法?Python redirect怎么用?Python redirect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了redirect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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))
开发者ID:comlounge,项目名称:camper,代码行数:26,代码来源:ticketwizard.py


示例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)
开发者ID:comlounge,项目名称:camper,代码行数:31,代码来源:registration.py


示例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)
开发者ID:comlounge,项目名称:userbase,代码行数:27,代码来源:registration.py


示例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))
开发者ID:comlounge,项目名称:camper,代码行数:29,代码来源:registration.py


示例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))
开发者ID:cryu,项目名称:camper,代码行数:35,代码来源:registration.py


示例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)
开发者ID:comlounge,项目名称:userbase,代码行数:25,代码来源:activation.py


示例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"))
开发者ID:comlounge,项目名称:maparticipate,代码行数:8,代码来源:decorators.py


示例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)
开发者ID:cryu,项目名称:camper,代码行数:8,代码来源:base.py


示例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))
开发者ID:comlounge,项目名称:camper,代码行数:10,代码来源:permissions.py


示例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))
开发者ID:cryu,项目名称:camper,代码行数:13,代码来源:permissions.py


示例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))
开发者ID:cryu,项目名称:camper,代码行数:15,代码来源:permissions.py


示例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")
开发者ID:comlounge,项目名称:userbase,代码行数:33,代码来源:login.py


示例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()
开发者ID:comlounge,项目名称:userbase,代码行数:25,代码来源:pw_forgot.py


示例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))
开发者ID:comlounge,项目名称:maparticipate,代码行数:7,代码来源:proposal.py


示例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"))
开发者ID:comlounge,项目名称:camper,代码行数:29,代码来源:delete.py


示例16: get

    def get(self, slug = None):
        """render the view"""

        tickets = self.config.dbs.tickets
        userbase = self.app.module_map.userbase

        ticket_classes = self.barcamp.ticketlist
        for tc in ticket_classes:
            for status in ['pending', 'confirmed', 'canceled', 'cancel_request']:
                tc[status] = tickets.get_tickets(
                    barcamp_id = self.barcamp._id,
                    ticketclass_id = tc._id,
                    status = status)
                # compute users
                uids = [t.user_id for t in tc[status]]
                users = userbase.get_users_by_ids(uids)
                userdict = {}
                for user in users:
                    userdict[str(user._id)] = user
                for ticket in tc[status]:
                    ticket['user'] = userdict[ticket.user_id]

        # make sure we are supposed to be shown
        if not self.barcamp.ticketmode_enabled:
            self.flash(self._('Ticketing Mode not enabled.'), category="danger")
            return redirect(self.url_for("barcamps.admin_ticketeditor", slug = self.barcamp.slug))

        return self.render(
            view = self.barcamp_view,
            barcamp = self.barcamp,
            ticket_classes = ticket_classes,
            title = self.barcamp.name)
开发者ID:comlounge,项目名称:camper,代码行数:32,代码来源:ticketlist.py


示例17: get

    def get(self, slug = None):
        """render the view"""
        form = ParticipantDataEditForm(self.request.form, config = self.config)
        registration_form = self.barcamp.registration_form
        if self.request.method == 'POST' and form.validate():
            f = form.data
            f['name'] = unicode(uuid.uuid4())
            
            # clean up choices
            new_choices = []
            for c in f['choices'].split("\n"):
                choice = c.strip()
                if choice:
                    new_choices.append((choice, choice)) # value and name are the same

            f['choices'] = new_choices

            self.barcamp.registration_form.append(f)
            self.barcamp.save()
            return redirect(self.url_for("barcamps.registration_form_editor", slug = self.barcamp.slug))

        return self.render(
            view = self.barcamp_view,
            barcamp = self.barcamp,
            title = self.barcamp.name,
            form = form,
            fields = self.barcamp.registration_form,
            **self.barcamp
        )
开发者ID:comlounge,项目名称:camper,代码行数:29,代码来源:customfields.py


示例18: get

    def get(self):
        """render the view"""
        form = BarcampAddForm(self.request.form, config = self.config)
        if self.request.method == 'POST' and form.validate():
            f = form.data
            f['admins'] = [self.user._id]
            f['created_by'] = self.user._id
            f['subscribers'] = [self.user._id]
            f['location'] = {
                'name'      : f['location_name'],
                'street'    : f['location_street'],
                'city'      : f['location_city'],
                'zip'       : f['location_zip'],
                'email'     : f['location_email'],
                'phone'     : f['location_phone'],
                'url'       : f['location_url'],
                'description' : f['location_description'],
                'country'   : 'de',
            }

            pid = unicode(uuid.uuid4())[:8]
            pid = f['planning_pad'] = "%s_%s" %(f['slug'],pid)
            did = f['slug']
            try:
                self.config.etherpad.createPad(padID=pid, text=u"Planung")
                self.config.etherpad.createPad(padID=did, text=u"Dokumentation")
            except:
                self.flash(self._("Attention: One or both of the etherpads exist already!"), category="warning")
                pass
            f['documentation_pad'] = did

            # retrieve geo location
            if form.data['location_street']:
                url = "http://nominatim.openstreetmap.org/search?q=%s, %s&format=json&polygon=0&addressdetails=1" %(
                    form.data['location_street'],
                    form.data['location_city'],
                )
                data = requests.get(url).json()
                if len(data)==0:
                    # trying again but only with city
                    url = "http://nominatim.openstreetmap.org/search?q=%s&format=json&polygon=0&addressdetails=1" %(
                        form.data['location_city'],
                    )
                    data = requests.get(url).json()
                if len(data)==0:
                    self.flash(self._("the city was not found in the geo database"), category="danger")
                    return self.render(form = form)
                # we have at least one entry, take the first one
                result = data[0]
                f['location']['lat'] = result['lat']
                f['location']['lng'] = result['lon']

            # create and save the barcamp object
            barcamp = db.Barcamp(f, collection = self.config.dbs.barcamps)
            barcamp = self.config.dbs.barcamps.put(barcamp)

            self.flash(self._("%s has been created") %f['name'], category="info")
            return redirect(self.url_for("index"))
        return self.render(form = form, slug = None)
开发者ID:cryu,项目名称:camper,代码行数:59,代码来源:add.py


示例19: get

 def get(self):
     """show the login form"""
     cfg = self.module.config
     self.module.logout(self)
     self.flash(self._(u"You are now logged out."))
     url_for_params = cfg.urls.logout_success
     url = self.url_for(**url_for_params)
     return redirect(url)
开发者ID:comlounge,项目名称:userbase,代码行数:8,代码来源:logout.py


示例20: delete

 def delete(self, slug = None, page_slug = None):
     """delete a page"""
     self.page.remove()
     self.flash(self._(u"the page has been deleted"))
     if self.barcamp is not None:
         url = self.url_for("barcamps.index", slug = self.barcamp.slug)
     else:
         url = self.url_for("index")
     return redirect(url)
开发者ID:RealJTG,项目名称:camper,代码行数:9,代码来源:view.py



注:本文中的starflyer.redirect函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python start.start_cfg函数代码示例发布时间:2022-05-27
下一篇:
Python log.warn函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap