Example #1
0
def edit(request, slug):
    team = Team.get(slug, request.user)

    if not team.is_member(request.user):
        raise Http404

    if not team.is_manager(request.user):
        return {'team': team}

    if request.method == 'POST':
        if request.user.is_staff:
            form = EditTeamFormAdmin(request.POST,
                                     request.FILES,
                                     instance=team)
        else:
            form = EditTeamForm(request.POST, request.FILES, instance=team)
        if form.is_valid():
            form.save()
            messages.success(request, _(u'Your changes have been saved'))
            return redirect(team.get_edit_url())
    else:
        if request.user.is_staff:
            form = EditTeamFormAdmin(instance=team)
        else:
            form = EditTeamForm(instance=team)
    return {'form': form, 'team': team}
Example #2
0
def edit(request, slug):
    team = Team.get(slug, request.user)

    if not team.is_member(request.user):
        raise Http404
    
    if not team.is_manager(request.user):
        return {
            'team': team
        }
    
    if request.method == 'POST':
        if request.user.is_staff:
            form = EditTeamFormAdmin(request.POST, request.FILES, instance=team)
        else:
            form = EditTeamForm(request.POST, request.FILES, instance=team)
        if form.is_valid():
            form.save()
            messages.success(request, _(u'Your changes have been saved'))
            return redirect(team.get_edit_url())
    else:
        if request.user.is_staff:
            form = EditTeamFormAdmin(instance=team)
        else:
            form = EditTeamForm(instance=team)
    return {
        'form': form,
        'team': team
    }