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


Python seaserv.check_group_staff函数代码示例

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


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

示例1: group_add

def group_add(request, gid):
    group_id_int = int(gid)     # Checked by URL Conf

    if not check_group_staff(group_id_int, request.user):
        raise Http404

    group = ccnet_threaded_rpc.get_group(group_id_int)
    if not group:
        return HttpResponseRedirect(reverse('group_list', args=[]))

    # change navigator when user in diffent context
    org, base_template = check_and_get_org_by_group(group_id_int,
                                                    request.user.username)
    
    form = GroupAvatarForm(request.POST or None, request.FILES or None)

    if request.method == 'POST' and 'avatar' in request.FILES:
        if form.is_valid():
            image_file = request.FILES['avatar']
            avatar = GroupAvatar()
            avatar.group_id = gid
            avatar.avatar.save(image_file.name, image_file)
            avatar.save()
            # invalidate group avatar cache
            invalidate_group_cache(gid)

            messages.success(request, _("Successfully uploaded a new group avatar."))
        else:
            messages.error(request, form.errors['avatar'])

        return HttpResponseRedirect(_get_next(request))
    else:
        # Only allow post request to change group avatar.
         raise Http404   
开发者ID:beride,项目名称:seahub,代码行数:34,代码来源:views.py

示例2: group_message_remove

def group_message_remove(request, group_id, msg_id):
    """
    Remove group message and all message replies and attachments.
    """
    # Checked by URL Conf
    group_id_int = int(group_id)
    msg_id = int(msg_id)
    group = get_group(group_id_int)
    if not group:
        raise Http404

    # Test whether user is in the group
    if not is_group_user(group_id_int, request.user.username):
        raise Http404

    try:
        gm = GroupMessage.objects.get(id=msg_id)
    except GroupMessage.DoesNotExist:
        return HttpResponse(
            json.dumps({"success": False, "err_msg": _(u"The message doesn't exist")}),
            content_type="application/json; charset=utf-8",
        )
    else:
        # Test whether user is group admin or message owner.
        if seaserv.check_group_staff(group_id, request.user.username) or gm.from_email == request.user.username:
            gm.delete()
            return HttpResponse(json.dumps({"success": True}), content_type="application/json; charset=utf-8")
        else:
            return HttpResponse(
                json.dumps({"success": False, "err_msg": _(u"You don't have the permission.")}),
                content_type="application/json; charset=utf-8",
            )
开发者ID:octomike,项目名称:seahub,代码行数:32,代码来源:views.py

示例3: _decorated

 def _decorated(request, *args, **kwargs):
     try:
         group_id = int(kwargs.get('group_id', None))
     except TypeError:
         raise TypeError("No group_id in url arguments")
     
     if check_group_staff(group_id, request.user.username):
         return func(request, *args, **kwargs)
     raise Http404
开发者ID:3c7,项目名称:seahub,代码行数:9,代码来源:decorators.py

示例4: is_group_repo_staff

def is_group_repo_staff(request, repo_id, username):
    is_staff = False

    repo_owner = get_repo_owner(request, repo_id)

    if '@seafile_group' in repo_owner:
        group_id = email2nickname(repo_owner)
        is_staff = seaserv.check_group_staff(group_id, username)

    return is_staff
开发者ID:haiwen,项目名称:seahub,代码行数:10,代码来源:repo.py

示例5: put

    def put(self, request, group_id):
        """ Rename, transfer a specific group
        """

        group = seaserv.get_group(group_id)
        username = request.user.username

        new_group_name = request.data.get('name', None)
        if new_group_name:
            # rename a group
            # Check whether group name is validate.
            if not validate_group_name(new_group_name):
                error_msg = _(u'Group name can only contain letters, numbers, blank, hyphen or underscore')
                return api_error(status.HTTP_400_BAD_REQUEST, error_msg)

            # Check whether group name is duplicated.
            if check_group_name_conflict(request, new_group_name):
                error_msg = _(u'There is already a group with that name.')
                return api_error(status.HTTP_400_BAD_REQUEST, error_msg)

            try:
                seaserv.ccnet_threaded_rpc.set_group_name(group_id, new_group_name)
            except SearpcError as e:
                logger.error(e)
                error_msg = _(u'Internal Server Error')
                return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)

        new_creator= request.data.get('creator', None)
        if new_creator:
            # transfer a group
            if not is_valid_username(new_creator):
                error_msg = _('Creator %s is not valid.') % new_creator
                return api_error(status.HTTP_400_BAD_REQUEST, error_msg)

            if new_creator == group.creator_name:
                error_msg = _('%s is already group owner') % new_creator
                return api_error(status.HTTP_400_BAD_REQUEST, error_msg)

            try:
                if not seaserv.is_group_user(group_id, new_creator):
                    seaserv.ccnet_threaded_rpc.group_add_member(group_id, username, new_creator)

                if not seaserv.check_group_staff(group_id, new_creator):
                    seaserv.ccnet_threaded_rpc.group_set_admin(group_id, new_creator)

                seaserv.ccnet_threaded_rpc.set_group_creator(group_id, new_creator)
            except SearpcError as e:
                logger.error(e)
                error_msg = _(u'Internal Server Error')
                return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)

        # get new info of this group
        group_info = get_group_info(request, group_id, GROUP_AVATAR_DEFAULT_SIZE)

        return Response(group_info)
开发者ID:ERamseth,项目名称:seahub,代码行数:55,代码来源:groups.py

示例6: repo_remove_share

def repo_remove_share(request):
    """
    If repo is shared from one person to another person, only these two peson
    can remove share.
    If repo is shared from one person to a group, then only the one share the
    repo and group staff can remove share.
    """
    repo_id = request.GET.get('repo_id', '')
    group_id = request.GET.get('gid', '')
    from_email = request.GET.get('from', '')
    if not is_valid_username(from_email):
        return render_error(request, _(u'Argument is not valid'))
    username = request.user.username

    # if request params don't have 'gid', then remove repos that share to
    # to other person; else, remove repos that share to groups
    if not group_id:
        to_email = request.GET.get('to', '')
        if not is_valid_username(to_email):
            return render_error(request, _(u'Argument is not valid'))

        if username != from_email and username != to_email:
            return render_permission_error(request, _(u'Failed to remove share'))

        if is_org_context(request):
            org_id = request.user.org.org_id
            org_remove_share(org_id, repo_id, from_email, to_email)
        else:
            seaserv.remove_share(repo_id, from_email, to_email)
    else:
        try:
            group_id = int(group_id)
        except:
            return render_error(request, _(u'group id is not valid'))

        group = seaserv.get_group(group_id)
        if not group:
            return render_error(request, _(u"Failed to unshare: the group doesn't exist."))

        if not seaserv.check_group_staff(group_id, username) \
                and username != from_email:
            return render_permission_error(request, _(u'Failed to remove share'))

        if is_org_group(group_id):
            org_id = get_org_id_by_group(group_id)
            del_org_group_repo(repo_id, org_id, group_id)
        else:
            seafile_api.unset_group_repo(repo_id, group_id, from_email)

    messages.success(request, _('Successfully removed share'))

    next = request.META.get('HTTP_REFERER', SITE_ROOT)
    return HttpResponseRedirect(next)
开发者ID:allo-,项目名称:seahub,代码行数:53,代码来源:views.py

示例7: group_remove_member

def group_remove_member(request, group_id, user_name):
    try:
        group_id_int = int(group_id)
    except ValueError:
        return render_error(request, _(u"group id is not valid"))

    if not check_group_staff(group_id_int, request.user):
        raise Http404

    try:
        ccnet_threaded_rpc.group_remove_member(group_id_int, request.user.username, user_name)
        seafserv_threaded_rpc.remove_repo_group(group_id_int, user_name)
        messages.success(request, _(u"Operation succeeded."))
    except SearpcError, e:
        messages.error(request, _(u"Failed:%s") % e.msg)
开发者ID:hilerchyn,项目名称:seahub,代码行数:15,代码来源:views.py

示例8: repo_remove_share

def repo_remove_share(request):
    """
    If repo is shared from one person to another person, only these two peson
    can remove share.
    If repo is shared from one person to a group, then only the one share the
    repo and group staff can remove share.
    """
    repo_id = request.GET.get('repo_id', '')
    group_id = request.GET.get('gid', '')
    from_email = request.GET.get('from', '')
    if not is_valid_username(from_email):
        return render_error(request, _(u'Argument is not valid'))

    # if request params don't have 'gid', then remove repos that share to
    # to other person; else, remove repos that share to groups
    if not group_id:
        to_email = request.GET.get('to', '')
        if not is_valid_username(to_email):
            return render_error(request, _(u'Argument is not valid'))

        if request.user.username != from_email and \
                request.user.username != to_email:
            return render_permission_error(request, _(u'Failed to remove share'))
        remove_share(repo_id, from_email, to_email)
    else:
        try:
            group_id_int = int(group_id)
        except:
            return render_error(request, _(u'group id is not valid'))

        if not check_group_staff(group_id_int, request.user.username) \
                and request.user.username != from_email:
            return render_permission_error(request, _(u'Failed to remove share'))

        if is_org_group(group_id_int):
            org_id = get_org_id_by_group(group_id_int)
            del_org_group_repo(repo_id, org_id, group_id_int)
        else:
            from seahub.group.views import group_unshare_repo
            group_unshare_repo(request, repo_id, group_id_int, from_email)

    messages.success(request, _('Successfully removed share'))

    next = request.META.get('HTTP_REFERER', None)
    if not next:
        next = SITE_ROOT

    return HttpResponseRedirect(next)
开发者ID:tostadora,项目名称:seahub,代码行数:48,代码来源:views.py

示例9: group_unshare_repo

def group_unshare_repo(request, repo_id, group_id, from_email):
    """
    Unshare a repo in group.
    
    """
    # Check whether group exists
    group = get_group(group_id)
    if not group:
        return render_error(request, _(u"Failed to unshare: the group doesn't exist."))

    # Check whether user is group staff or the one share the repo
    if not check_group_staff(group_id, from_email) and \
            seafserv_threaded_rpc.get_group_repo_owner(repo_id) != from_email:
        return render_permission_error(request, _(u"Operation failed: only administrators and the owner of the library can unshare it."))
        
    if seafserv_threaded_rpc.group_unshare_repo(repo_id, group_id, from_email) != 0:
        return render_error(request, _(u"Failed to unshare: internal error."))
开发者ID:chuyskywalker,项目名称:seahub,代码行数:17,代码来源:views.py

示例10: group_wiki

def group_wiki(request, group, page_name="home"):
    is_staff = True if check_group_staff(group.id, request.user) else False
    username = request.user.username
    content = ''
    wiki_exists = True
    last_modified, latest_contributor = None, None
    try:
        content, repo_id, obj_id = get_wiki_page(request, group, page_name)
    except WikiDoesNotExist:
        wiki_exists = False
    except WikiPageMissing:
        '''create that page for user'''
        repo = find_wiki_repo(request, group)
        # No need to check whether repo is none, since repo is already created
        
        filename = normalize_page_name(page_name) + '.md'
        if not post_empty_file(repo.id, "/", filename, username):
            return render_error(request, _("Faied to create wiki page. Please retry later."))
        return HttpResponseRedirect(reverse('group_wiki', args=[group.id, page_name]))
    else:
        content = convert_wiki_link(content, group, repo_id, username)
        
        # fetch file latest contributor and last modified
        path = '/' + page_name + '.md'
        file_path_hash = md5_constructor(urllib2.quote(path.encode('utf-8'))).hexdigest()[:12]            
        contributors, last_modified, last_commit_id = get_file_contributors(\
            repo_id, path.encode('utf-8'), file_path_hash, obj_id)
        latest_contributor = contributors[0] if contributors else None

    return render_to_response("group/group_wiki.html", {
            "group_id": group.id,
            "group" : group,
            "is_staff": is_staff,
            "content": content,
            "page": page_name,
            "wiki_exists": wiki_exists,
            "last_modified": last_modified,
            "latest_contributor": latest_contributor,
            }, context_instance=RequestContext(request))
开发者ID:beride,项目名称:seahub,代码行数:39,代码来源:views.py

示例11: _decorated

    def _decorated(view, request, group_id, *args, **kwargs):
        group_id = int(group_id) # Checked by URL Conf
        try:
            group = seaserv.get_group(group_id)
        except SearpcError as e:
            logger.error(e)
            error_msg = _(u'Internal Server Error')
            return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)

        if not group:
            error_msg = _(u'Group does not exist.')
            return api_error(status.HTTP_400_BAD_REQUEST, error_msg)

        username = request.user.username
        try:
            is_group_member = seaserv.is_group_user(group_id,
                                                    username)
        except SearpcError as e:
            logger.error(e)
            error_msg = _(u'Internal Server Error')
            return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)

        if not is_group_member:
            error_msg = _(u'Permission denied')
            return api_error(status.HTTP_403_FORBIDDEN, error_msg)

        try:
            is_group_staff = seaserv.check_group_staff(group_id, username)
        except SearpcError as e:
            logger.error(e)
            error_msg = _(u'Internal Server Error')
            return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)

        if not is_group_staff:
            error_msg = _(u'Permission denied')
            return api_error(status.HTTP_403_FORBIDDEN, error_msg)

        return func(view, request, group_id, *args, **kwargs)
开发者ID:ERamseth,项目名称:seahub,代码行数:38,代码来源:utils.py

示例12: get_group_member_info

def get_group_member_info(request, group_id, email, avatar_size=AVATAR_DEFAULT_SIZE):
    p = Profile.objects.get_profile_by_user(email)
    if p:
        login_id = p.login_id if p.login_id else ''
    else:
        login_id = ''

    try:
        avatar_url, is_default, date_uploaded = api_avatar_url(email, avatar_size)
    except Exception as e:
        logger.error(e)
        avatar_url = get_default_avatar_url()

    is_admin = seaserv.check_group_staff(group_id, email)
    member_info = {
        "name": email2nickname(email),
        'email': email,
        "contact_email": Profile.objects.get_contact_email_by_user(email),
        "login_id": login_id,
        "avatar_url": request.build_absolute_uri(avatar_url),
        "is_admin": is_admin,
    }

    return member_info
开发者ID:AviorAlong,项目名称:haiwen-5.1.3,代码行数:24,代码来源:utils.py

示例13: is_group_admin

def is_group_admin(group_id, email):
    return seaserv.check_group_staff(group_id, email)
开发者ID:AviorAlong,项目名称:haiwen-5.1.3,代码行数:2,代码来源:utils.py

示例14: render_group_info

def render_group_info(request, group_id, form):
    group_id_int = int(group_id) # Checkeb by URL Conf

    # remove user notifications
    UserNotification.objects.filter(to_user=request.user.username,
                                    msg_type='group_msg',
                                    detail=str(group_id)).delete()
    
    group = get_group(group_id_int)
    if not group:
        return HttpResponseRedirect(reverse('group_list', args=[]))

    # Get all group members.
    members = get_group_members(group_id_int)
    
    # Check whether user belongs to the group.
    joined = is_group_user(group_id_int, request.user.username)
    if not joined and not request.user.is_staff:
        # Return group public info page.
        return render_to_response('group/group_pubinfo.html', {
                'members': members,
                'group': group,
                }, context_instance=RequestContext(request))

    is_staff = True if check_group_staff(group.id, request.user) else False
        

    org = request.user.org
    if org:
        repos = get_org_group_repos(org['org_id'], group_id_int,
                                    request.user.username)
    else:
        repos = get_group_repos(group_id_int, request.user.username)

    recent_commits = []
    cmt_repo_dict = {}
    for repo in repos:
        repo.user_perm = check_permission(repo.props.id, request.user.username)
        cmmts = get_commits(repo.props.id, 0, 10)
        for c in cmmts:
            cmt_repo_dict[c.id] = repo
        recent_commits += cmmts

    recent_commits.sort(lambda x, y : cmp(y.props.ctime, x.props.ctime))
    recent_commits = recent_commits[:15]
    for cmt in recent_commits:
        cmt.repo = cmt_repo_dict[cmt.id]
        cmt.repo.password_set = is_passwd_set(cmt.props.repo_id,
                                              request.user.username)
        cmt.tp = cmt.props.desc.split(' ')[0]


    return render_to_response("group/group_info.html", {
            "members": members,
            "repos": repos,
            "recent_commits": recent_commits,
            "group_id": group_id,
            "group" : group,
            "is_staff": is_staff,
            "is_join": joined,
            "form": form,
            'create_shared_repo': True,
            'group_members_default_display': GROUP_MEMBERS_DEFAULT_DISPLAY,
            }, context_instance=RequestContext(request));
开发者ID:beride,项目名称:seahub,代码行数:64,代码来源:views.py

示例15: is_group_staff

def is_group_staff(group, user):
    if user.is_anonymous():
        return False
    return seaserv.check_group_staff(group.id, user.username)
开发者ID:octomike,项目名称:seahub,代码行数:4,代码来源:views.py


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