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


Python Submission.get方法代码示例

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


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

示例1: update_group

# 需要导入模块: from models import Submission [as 别名]
# 或者: from models.Submission import get [as 别名]
    def update_group(self, key):
        if not auth.logged_in():
            return self.redirect('/groups')
        
        user = auth.current_user()
        group = Group.get(key)
        if group.owner.user_id() != user.user_id() and not auth.user_is_admin():
            Messages.add('Only the owner of the group owner may modify it')
            return self.redirect('/groups')
        
        name = self.request.get('name')
        public = self.request.get('public') == 'public'
        abandon = self.request.get('abandon-project')
        sub_text = self.request.get('submission-text')
        sub_url = self.request.get('submission-url')
        remove_submission = self.request.get_all('remove-submission')
        remove = self.request.get_all('remove')
        owner = self.request.get('owner')
        delete = self.request.get('delete')
        
        if delete:
            group.delete()
            return self.redirect('/groups')
        
        group.name = name
        group.public = public
        
        if abandon:
            group.project = None
        
        if sub_text and sub_url:
            Submission(text=sub_text, url=sub_url, group=group).put()

        for sub in Submission.get(remove_submission):
            sub.delete()

        pending  = list(group.pending_users)
        for user in pending:
            approve = self.request.get("approve-%s" % user)
            if approve == "approve":
                group.members.append(user)
                group.pending_users.remove(user)
            elif approve == "refuse":
                group.pending_users.remove(user)
        
        group.owner = auth.user_from_email(owner)
        
        for user in remove:
            if auth.user_from_email(user) == group.owner:
                Messages.add('Cannot remove the group owner')
                return self.redirect('/groups/%s/edit' % key)
            else:
                group.members.remove(auth.user_from_email(user))
        
        group.put()
        return self.redirect('/groups/%s' % key)
开发者ID:DanAlbert,项目名称:d20mgr,代码行数:58,代码来源:back.main.py

示例2: update_group

# 需要导入模块: from models import Submission [as 别名]
# 或者: from models.Submission import get [as 别名]
    def update_group(self, key):
        """Updates a group with information from the moderation form.

        Form Variables:
            name:              the name of the group
            public:            true if the group should be joinable by the
                               public
            abandon-project:   true if the group moderator wants to abandon the
                               current project
            submission-text:   the text to be displayed for the new submission
            submission-url:    the URL of the new submission
            remove-submission: a list of submissions to be removed
            remove:            a list of users to be removed from the group
            owner:             the owner of the group
            delete:            true if the group moderator wants to disband the
                               group
        """
        if not auth.logged_in():
            return self.redirect('/groups')

        user = auth.current_user()
        group = Group.get(key)
        if (group.owner.user_id() != user.user_id() and
                not auth.user_is_admin()):
            Messages.add('Only the owner of the group owner may modify it')
            return self.redirect('/groups')

        name = self.request.get('name')
        public = self.request.get('public') == 'public'
        abandon = self.request.get('abandon-project')
        sub_text = self.request.get('submission-text')
        sub_url = self.request.get('submission-url')
        remove_submission = self.request.get_all('remove-submission')
        remove = self.request.get_all('remove')
        owner = self.request.get('owner')
        delete = self.request.get('delete')

        if delete:
            group.delete()
            return self.redirect('/groups')

        group.name = name
        group.public = public

        if abandon:
            group.project = None

        if sub_text and sub_url:
            Submission(text=sub_text, url=sub_url, group=group).put()

        for sub in Submission.get(remove_submission):
            sub.delete()

        pending = list(group.pending_users)
        for user in pending:
            approve = self.request.get("approve-%s" % user)
            if approve == "approve":
                group.members.append(user)
                group.pending_users.remove(user)
            elif approve == "refuse":
                group.pending_users.remove(user)

        group.owner = auth.user_from_email(owner)

        for user in remove:
            if auth.user_from_email(user) == group.owner:
                Messages.add('Cannot remove the group owner')
                return self.redirect('/groups/%s/edit' % key)
            else:
                group.members.remove(auth.user_from_email(user))

        group.put()
        return self.redirect('/groups/%s' % key)
开发者ID:ryleyherrington,项目名称:app_hackathon,代码行数:75,代码来源:main.py


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