当前位置: 首页>>代码示例>>Python>>正文


Python Member.get_current_member方法代码示例

本文整理汇总了Python中models.Member.get_current_member方法的典型用法代码示例。如果您正苦于以下问题:Python Member.get_current_member方法的具体用法?Python Member.get_current_member怎么用?Python Member.get_current_member使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Member的用法示例。


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

示例1: post

# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import get_current_member [as 别名]
    def post(self):
        if len(self.request.POST) == 4 and 'handle' in self.request.POST \
                and 'real_name' in self.request.POST \
                and 'email' in self.request.POST \
                and 'bio' in self.request.POST:

            handle = self.request.POST.getall('handle')[0]
            template_dict = {}
            member = Member.get_current_member()
            other = Member.gql('WHERE handle = :1', handle).get()

            if (not handle or len(handle) > 12 or
                any(l not in self.valid_letters for l in handle)):
                template_dict['error'] = 'Pick something sensible, you moron.'

            elif other and other.user_id != member.user_id:
                template_dict['error'] = 'Sorry, already taken.'

            elif handle.lower() in self.banned_names:
                template_dict['error'] = self.banned_names[handle]

            else:
                real_name = self.request.POST.getall('real_name')[0]
                if real_name:
                    member.real_name = real_name
                email = self.request.POST.getall('email')[0]
                if email:
                    member.email = email
                bio = self.request.POST.getall('bio')[0]
                if bio:
                    member.bio = bio
                member.handle = handle
                member.save()
                template_dict['error'] = 'Profile updated'
            self.render_template('account', template_dict)
开发者ID:Man-UP,项目名称:website,代码行数:37,代码来源:handlers.py

示例2: get

# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import get_current_member [as 别名]
 def get(self, key):
     edit = self.request.get('edit')
     template_dict = {'key': key, 'show_form' : True,'members': Member.all(),
                      'edit':edit,'thing' : self.thing_descriptors.get(edit),'images':Image.all().filter('name != ', "no-name") }
     if key == 'new':
         template_dict['form_data'] = {
             'author': Member.get_current_member().handle,
             'date': unicode(datetime.date.today())}
     else:
         try:
             if(edit=='news'):
                thing = NewsArticleNew.get(Key(key))
                form_data={'title':thing.title,'author':thing.author,'date':unicode(thing.date),'body':thing.body,'picture':thing.picture}
             elif(edit=='talk'):
                thing = TalkNew.get(Key(key))
                form_data={'title':thing.title,'author':thing.author,'date':unicode(thing.date),'body':thing.body,'video':thing.video}
             elif(edit=='hack'):
                thing = Hack.get(Key(key))
                form_data={'title':thing.title,'date':unicode(thing.date),'body':thing.body,'picture':thing.picture}
             template_dict['form_data']=form_data
         except BadKeyError:
             template_dict['message'] = \
                 'Could not find %s with key %r.' %  (self.thing_descriptors.get(edit), key)
             template_dict['show_form'] = False
     self.render_template('edit', template_dict)
开发者ID:Man-UP,项目名称:website,代码行数:27,代码来源:handlers.py

示例3: render_template

# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import get_current_member [as 别名]
    def render_template(self, template_name, template_dict=None):
        tag_line = 'Next meeting coming soon'

        if template_dict is None:
            template_dict = {}

        user = Member.get_current_member()

        if user:
            if self.login_required:
                redirect_target = '/'
            else:
                redirect_target = self.request.path
            url_creator = users.create_logout_url
        else:
            redirect_target = '/login?url=%s' % self.request.path
            url_creator = users.create_login_url

        defaults = {
            'user': user,
            'is_admin': users.is_current_user_admin(),
            'log_url': url_creator(redirect_target),
            'tag_line': tag_line,
            'title': self.title
        }

        for key in defaults:
            if key not in template_dict:
                template_dict[key] = defaults[key]

        template_path = get_path(
            os.path.join('templates', '%s.html' % template_name)
        )
        self.response.out.write(template.render(template_path, template_dict))
开发者ID:eldog,项目名称:man-up-website,代码行数:36,代码来源:handlers.py

示例4: get

# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import get_current_member [as 别名]
 def get(self, key):
     template_dict = {'key': key, 'show_form' : True}
     if key == 'new':
         template_dict['form_data'] = {
             'title': '',
             'author': Member.get_current_member().handle,
             'date': datetime.date.today(),
             'body': ''}
     else:
         try:
             template_dict['form_data'] = NewsArticle.get(Key(key))
         except BadKeyError:
             template_dict['message'] = \
                 'Could not find article with key %r.' % key
             template_dict['show_form'] = False
     self.render_template('edit', template_dict)
开发者ID:eldog,项目名称:man-up,代码行数:18,代码来源:handlers.py

示例5: post

# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import get_current_member [as 别名]
 def post(self):
     post = self.request.POST
     if len(post) == 2 and 'badge' in post and 'proof' in post:
         body = 'Member: %s\nBadge: %s\nProof:\n%s' % (
             Member.get_current_member().handle,
             post['badge'],
             post['proof']
         )
         send_mail(
             sender='[email protected]',
             to='[email protected]',
             subject='Badge application',
             body=body
         )
         self.render_template('badge_application', {
             'message': 'Application submitted. \
                         It will be reviewed as soon as possible.'
         })
开发者ID:eldog,项目名称:man-up,代码行数:20,代码来源:handlers.py


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