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

Python helpers.flash函数代码示例

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

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



在下文中一共展示了flash函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: invitation

    def invitation(self, group):
        """Act on the invitation of the current user to this group."""
        if hasattr(self, 'form_result'):
            invitations = meta.Session.query(PendingInvitation
                            ).filter_by(group=group, user=c.user, active=True
                            ).all()

            if invitations:
                if self.form_result.get('accept', '') == 'True':
                    group.add_member(c.user)
                    if c.user.location is None:
                        c.user.location = group.location
                    h.flash(_("Congratulations! You are now a member of the group '%s'") % group.title)
                else:
                    h.flash(_("Invitation to group '%s' rejected.") % group.title)
                self._clear_requests(group, c.user)
                meta.Session.commit()

            came_from = self.form_result.get('came_from', None)
            if came_from is None:
                redirect(url(controller='group', action='home', id=group.group_id))
            else:
                redirect(came_from.encode('utf-8'))
        else:
            redirect(url(controller='group', action='home', id=group.group_id))
开发者ID:nous-consulting,项目名称:ututi,代码行数:25,代码来源:group.py


示例2: watch_subject

 def watch_subject(self):
     self._watch_subject()
     if request.params.has_key("js"):
         return "OK"
     else:
         h.flash(render_mako_def("subject/flash_messages.mako", "watch_subject", subject=self._getSubject()))
         redirect(request.referrer)
开发者ID:nous-consulting,项目名称:ututi,代码行数:7,代码来源:subjects.py


示例3: edit_student_group

    def edit_student_group(self, id):
        try:
            group = TeacherGroup.get(int(id))
        except ValueError:
            abort(404)

        if group is None or group.teacher != c.user:
            abort(404)

        c.student_group = group
        defaults = {
            'title' : group.title,
            'email' : group.email,
            'group_id' : group.id
            }
        if hasattr(self, 'form_result'):
            group.title = self.form_result['title']
            group.email = self.form_result['email']
            group.update_binding()
            meta.Session.commit()
            message = _(u'Group %(group_title)s (%(group_email)s) updated!') % {
                'group_title': group.title,
                'group_email': group.email}
            h.flash(message)
            redirect(url(controller='profile', action='dashboard'))
        return htmlfill.render(self._edit_student_group(), defaults=defaults)
开发者ID:nous-consulting,项目名称:ututi,代码行数:26,代码来源:teacher.py


示例4: invite_fb

    def invite_fb(self, group):
        # Handle POST.
        invited = request.params.get('ids[]')
        if invited:
            ids = invited.split(',')
            for facebook_id in ids:
                group.create_pending_fb_invitation(int(facebook_id), c.user)
            make_facebook_invitations(ids, c.user, group.location)
            meta.Session.commit()
            h.flash(ungettext('Invited %(num)d friend.',
                              'Invited %(num)d friends.',
                              len(ids)) % dict(num=len(ids)))
            redirect(c.group.url(action='members'))

        # Render page.
        fb_user = facebook.get_user_from_cookie(request.cookies,
                         config['facebook.appid'], config['facebook.secret'])
        c.has_facebook = fb_user is not None
        if c.has_facebook:
            try:
                graph = facebook.GraphAPI(fb_user['access_token'])
                friends = graph.get_object("me/friends")
            except facebook.GraphAPIError:
                c.has_facebook = False
        if not c.has_facebook:
            # Ask to log on to facebook.
            return render('group/invite.mako')

        friend_ids = [f['id'] for f in friends['data']]
        friend_users = meta.Session.query(User).filter(
                            User.facebook_id.in_(friend_ids)).all()
        c.exclude_ids = ','.join(str(u.facebook_id) for u in friend_users
                                 if c.group.is_member(u))
        return render('group/invite.mako')
开发者ID:nous-consulting,项目名称:ututi,代码行数:34,代码来源:group.py


示例5: document

    def document(self):
        resp = request.environ.get('pylons.original_response')
        req = request.environ.get('pylons.original_request')
        c.came_from = url.current()
        if resp is None:
            return render("/error.mako")

        c.reason = req.environ.get('ututi.access_denied_reason', None)
        if resp.status_int in [403, 404]:
            self.form_result = {}
            self._search()
            c.came_from = url('/')
            if resp.status_int == 403:
                return render("/access_denied.mako")

            elif resp.status_int == 404:
                h.flash(_("Document at %(url)s was not found, but maybe you are interested in something else?") % {
                        'url': req.url.encode('ascii', 'ignore')})

                # if user is logged in, show search form, otherwise - login form
                try:
                    if session['login']:
                        return render('/search/index.mako')
                except KeyError:
                    return render('/login.mako')

        return render("/error.mako")
开发者ID:nous-consulting,项目名称:ututi,代码行数:27,代码来源:error.py


示例6: update

    def update(self):
        values = {
            'fullname': None,
            'description': None,
            'profile_is_public': None,
            'url_name': None,
            'teacher_position': None,
            'teacher_sub_department': None,
        }
        values.update(self.form_result)

        c.user.fullname = values['fullname']
        if values['description'] is not None:
            # this check is needed because description field
            # is currently reused as teacher's information and
            # is not displayed for teacher in this form.
            c.user.description = values['description']
        c.user.profile_is_public = bool(values['profile_is_public'])
        c.user.url_name = values['url_name']
        if c.user.is_teacher:
            c.user.profile_is_public = True  # teacher profile always public
            c.user.teacher_position = values['teacher_position']  # additional teacher fields
            sd_id = values['teacher_sub_department']
            if sd_id is not None:
                if sd_id != '':
                    sd = meta.Session.query(SubDepartment).filter_by(id=sd_id).one()
                    if sd is not None:
                        c.user.sub_department = sd
                else:
                    c.user.sub_department = None
        meta.Session.commit()
        h.flash(_('Your profile was updated.'))
        redirect(url(controller='profile', action='edit'))
开发者ID:nous-consulting,项目名称:ututi,代码行数:33,代码来源:base.py


示例7: invite_friends_fb

    def invite_friends_fb(self):
        # handle facebook callback
        ids = request.params.get('ids[]')
        if ids:
            ids = map(int, ids.split(','))
            invited = make_facebook_invitations(ids, c.user, c.user.location)
            meta.Session.commit()
            if invited:
                h.flash(ungettext('Invited %(num)d friend.',
                                  'Invited %(num)d friends.',
                                  len(invited)) % dict(num=len(invited)))

            redirect(url(controller='profile', action='home'))

        # render page
        fb_user = facebook.get_user_from_cookie(request.cookies,
                      config['facebook.appid'], config['facebook.secret'])
        c.has_facebook = fb_user is not None
        if c.has_facebook:
            try:
                graph = facebook.GraphAPI(fb_user['access_token'])
                friends = graph.get_object("me/friends")
                friend_ids = [f['id'] for f in friends['data']]
                friend_users = meta.Session.query(User)\
                        .filter(User.facebook_id.in_(friend_ids))\
                        .filter(User.location == c.user.location).all()
                c.exclude_ids = ','.join(str(u.facebook_id) for u in friend_users)
            except facebook.GraphAPIError:
                c.has_facebook = False

        return render('profile/invite_friends_fb.mako')
开发者ID:nous-consulting,项目名称:ututi,代码行数:31,代码来源:base.py


示例8: delete_my_account

 def delete_my_account(self):
     if hasattr(self, 'form_result'):
             h.flash(_('Your account has been successfully removed!'))
             c.user.delete_user()
             meta.Session.commit()
             redirect(url(controller='home', action='logout'))
     redirect(url(controller='profile', action='login_settings'))
开发者ID:nous-consulting,项目名称:ututi,代码行数:7,代码来源:base.py


示例9: google_login

    def google_login(self):
        openid_session = session.get("openid_session", {})
        openid_store = None # stateless
        cons = Consumer(openid_session, openid_store)
        GOOGLE_OPENID = 'https://www.google.com/accounts/o8/id'
        openid = GOOGLE_OPENID
        try:
            authrequest = cons.begin(openid)
        except DiscoveryFailure:
            h.flash(_('Authentication failed, please try again.'))
            redirect(c.came_from or url(controller='home', action='index'))

        ax_req = ax.FetchRequest()
        ax_req.add(ax.AttrInfo('http://axschema.org/namePerson/first',
                               alias='firstname', required=True))
        ax_req.add(ax.AttrInfo('http://axschema.org/namePerson/last',
                               alias='lastname', required=True))
        ax_req.add(ax.AttrInfo('http://schema.openid.net/contact/email',
                               alias='email', required=True))
        authrequest.addExtension(ax_req)

        kargs = self._auth_args()

        redirecturl = authrequest.redirectURL(
            url('frontpage', qualified=True),
            return_to=url(controller='federation', action='google_verify',
                          qualified=True, **kargs))

        session['openid_session'] = openid_session
        session.save()
        redirect(redirecturl)
开发者ID:nous-consulting,项目名称:ututi,代码行数:31,代码来源:federation.py


示例10: link_google

    def link_google(self, registration):
        openid_session = session.get("openid_session", {})
        openid_store = None # stateless
        cons = Consumer(openid_session, openid_store)

        GOOGLE_OPENID = 'https://www.google.com/accounts/o8/id'
        try:
            authrequest = cons.begin(GOOGLE_OPENID)
        except DiscoveryFailure:
            h.flash(_('Authentication failed, please try again.'))
            redirect(registration.url(action='personal_info'))

        ax_req = ax.FetchRequest()
        ax_req.add(ax.AttrInfo('http://axschema.org/namePerson/first',
                               alias='firstname', required=True))
        ax_req.add(ax.AttrInfo('http://axschema.org/namePerson/last',
                               alias='lastname', required=True))
        ax_req.add(ax.AttrInfo('http://schema.openid.net/contact/email',
                               alias='email', required=True))
        authrequest.addExtension(ax_req)

        session['openid_session'] = openid_session
        session.save()

        realm = url(controller='home', action='index', qualified=True)
        return_to = registration.url(action='google_verify', qualified=True)

        redirect(authrequest.redirectURL(realm, return_to))
开发者ID:nous-consulting,项目名称:ututi,代码行数:28,代码来源:registration.py


示例11: register_teacher

    def register_teacher(self, location):
        # bounce existing users to different action
        if c.user is not None:
            redirect(location.url(action='register_teacher_existing'))

        if not hasattr(self, 'form_result'):
            return htmlfill.render(self._register_teacher_form())

        email = self.form_result['email']

        if User.get(email, location):
            h.flash(_('The email you entered is registered in Ututi. '
                      'Please login to proceed.'))
            destination = location.url(action='register_teacher_existing')
            redirect(url(controller='home', action='login', email=email,
                         came_from=destination))

        # lookup/create registration entry and send confirmation code to user
        registration = UserRegistration.create_or_update(location, email)
        registration.teacher = True
        meta.Session.commit()
        registration.send_confirmation_email()

        # show confirmation page
        c.email = email
        return render('registration/email_approval.mako')
开发者ID:nous-consulting,项目名称:ututi,代码行数:26,代码来源:location.py


示例12: _reject_post

    def _reject_post(self, group, thread, redirecturl=None, ajax=False):
        success = False
        if thread.in_moderation_queue:
            thread.reject()
            meta.Session.commit()
            success = True

        if ajax:
            if success:
                return render_mako_def('mailinglist/administration.mako',
                                       'rejectedMessage')
            else:
                return render_mako_def('mailinglist/administration.mako',
                                       'warningMessage')

        if success:
            h.flash(_("Message %(link_to_message)s has been rejected.") % {
                'link_to_message': h.link_to(thread.subject, thread.url())
            })
        else:
            h.flash(_("Could not reject %(link_to_message)s as it was already approved.") % {
                'link_to_message': h.link_to(thread.subject, thread.url())
            })

        if redirecturl is None:
            redirecturl = group.url(controller='mailinglist', action='administration')

        redirect(redirecturl)
开发者ID:nous-consulting,项目名称:ututi,代码行数:28,代码来源:mailinglist.py


示例13: post_anonymous

 def post_anonymous(self, group):
     post = post_message(group,
                         c.user,
                         self.form_result['subject'],
                         self.form_result['message'])
     h.flash(_('Your message to the group was successfully sent.'))
     redirect(group.url())
开发者ID:nous-consulting,项目名称:ututi,代码行数:7,代码来源:mailinglist.py


示例14: send_message

 def send_message(self):
     self._send_message(
         self.form_result['group'],
         self.form_result['subject'],
         self.form_result['message'],
         self.form_result.get('category_id', None))
     h.flash(_('Message sent.'))
     self._redirect()
开发者ID:nous-consulting,项目名称:ututi,代码行数:8,代码来源:wall.py


示例15: delete_email_domain

 def delete_email_domain(self, id):
     domain = EmailDomain.get(id)
     if domain is not None:
         domain.delete()
         meta.Session.commit()
     else:
         h.flash('Email domain with id %s does not exist' % id)
     redirect(url(controller='admin', action='email_domains'))
开发者ID:nous-consulting,项目名称:ututi,代码行数:8,代码来源:__init__.py


示例16: register_teacher_existing

    def register_teacher_existing(self, location):
        if c.user.is_teacher:
            h.flash(_('You already have a teacher account.'))
            redirect(url(controller='profile', action='home'))

        teacher_request_email(c.user)
        h.flash(_('Thank You! Your request to become a teacher has been received. We will notify You once we grant You the rights of a teacher.'))
        redirect(location.url())
开发者ID:nous-consulting,项目名称:ututi,代码行数:8,代码来源:location.py


示例17: update_wall_settings

 def update_wall_settings(self):
     if hasattr(self, 'form_result'):
         events = set(self.form_result.get('events', []))
         events = list(set(Event.event_types()) - events)
         c.user.update_ignored_events(events)
         meta.Session.commit()
         h.flash(_('Your wall settings have been updated.'))
     redirect(url(controller='profile', action='wall_settings'))
开发者ID:nous-consulting,项目名称:ututi,代码行数:8,代码来源:base.py


示例18: update_publications

    def update_publications(self):
        if not hasattr(self, 'form_result'):
            redirect(url(controller='profile', action='edit_publications'))

        c.user.publications = self.form_result['publications']
        meta.Session.commit()
        h.flash(_('Your publication page was updated.'))

        redirect(url(controller='profile', action='edit_publications'))
开发者ID:nous-consulting,项目名称:ututi,代码行数:9,代码来源:teacher.py


示例19: send_sms

 def send_sms(self):
     if hasattr(self, 'form_result'):
         msg = SMS(sender=c.user,
                   recipient_number=self.form_result.get('number'),
                   message_text=self.form_result.get('message'))
         meta.Session.add(msg)
         meta.Session.commit()
         h.flash('Message sent to number %s' % self.form_result.get('number'))
     redirect(url(controller='admin', action='sms'))
开发者ID:nous-consulting,项目名称:ututi,代码行数:9,代码来源:__init__.py


示例20: delete

 def delete(self, group):
     if len(group.members) > 1:
         h.flash(_("You can't delete a group while it has members!"))
         redirect(request.referrer)
     else:
         h.flash(_("Group '%(group_title)s' has been deleted!" % dict(group_title=group.title)))
         meta.Session.delete(group)
         meta.Session.commit()
         redirect(url(controller='profile', action='home'))
开发者ID:nous-consulting,项目名称:ututi,代码行数:9,代码来源:group.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python uu.decode函数代码示例发布时间:2022-05-26
下一篇:
Python base.render函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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