Exemple #1
0
def org_edit_photo(request, org_id):
    org = get_object_or_404(Organization, id=org_id)
    if not (request.user.is_staff or org.can_edit(request.user)):
        return HttpResponseForbidden("Forbidden")

    if request.method == 'POST':
        form = ProfileImageForm(request.POST, request.FILES)
        try:
            if form.is_valid():
                form.save()
                return HttpResponseRedirect(
                    reverse('member:org:view', kwargs={'org_id': org.id}))
            else:
                print(form)
        except Exception as e:
            messages.add_message(request, messages.ERROR,
                                 "Could not save: %s" % str(e))
    else:
        form = ProfileImageForm()

    context = {
        'organization': org,
        'form': form,
    }
    return render(request, 'member/profile/profile_image_edit.html', context)
Exemple #2
0
def edit_photo(request, username):
    user = get_object_or_404(User, username=username)
    if not user == request.user and not request.user.is_staff:
        return HttpResponseRedirect(
            reverse('member:profile:view',
                    kwargs={'username': request.user.username}))

    if request.method == 'POST':
        form = ProfileImageForm(request.POST, request.FILES)
        try:
            if form.is_valid():
                form.save()
                return HttpResponseRedirect(
                    reverse('member:profile:view',
                            kwargs={'username': request.user.username}))
            else:
                print form
        except Exception as e:
            messages.add_message(request, messages.ERROR,
                                 "Could not save: %s" % str(e))
    else:
        form = ProfileImageForm()

    context = {'user': user, 'form': form}
    return render(request, 'members/profile/profile_image_edit.html', context)
Exemple #3
0
def edit_photo(request, username):
    page_message = None
    user=get_object_or_404(User, username=username)
    if not user == request.user and not request.user.is_staff:
        return HttpResponseRedirect(reverse('member_profile', kwargs={'username': request.user.username}))

    if request.method == 'POST':
        form = ProfileImageForm(request.POST, request.FILES)
        try:
            if form.is_valid():
                form.save()
                return HttpResponseRedirect(reverse('member_profile', kwargs={'username': request.user.username}))
        except Exception as e:
            page_message = str(e)
    else:
        form = ProfileImageForm()

    context = {'user': user, 'page_message': page_message}
    return render(request, 'members/profile_image_edit.html', context)
Exemple #4
0
def edit_photo(request, username):
    user = get_object_or_404(User, username=username)
    if not user == request.user and not request.user.is_staff:
        return HttpResponseRedirect(reverse('member:profile:view', kwargs={'username': request.user.username}))

    if request.method == 'POST':
        form = ProfileImageForm(request.POST, request.FILES)
        try:
            if form.is_valid():
                form.save()
                return HttpResponseRedirect(reverse('member:profile:view', kwargs={'username': user.username}))
            else:
                print(form)
        except Exception as e:
            messages.add_message(request, messages.ERROR, "Could not save: %s" % str(e))
    else:
        form = ProfileImageForm()

    context = {'user': user, 'form': form}
    return render(request, 'member/profile/profile_image_edit.html', context)
Exemple #5
0
def org_edit_photo(request, org_id):
    org = get_object_or_404(Organization, id=org_id)
    if not (request.user.is_staff or org.can_edit(request.user)):
        return HttpResponseForbidden("Forbidden")

    if request.method == 'POST':
        form = ProfileImageForm(request.POST, request.FILES)
        try:
            if form.is_valid():
                form.save()
                return HttpResponseRedirect(reverse('member:org:view', kwargs={'org_id': org.id}))
            else:
                print(form)
        except Exception as e:
            messages.add_message(request, messages.ERROR, "Could not save: %s" % str(e))
    else:
        form = ProfileImageForm()

    context = {
        'organization': org,
        'form': form,
    }
    return render(request, 'member/profile/profile_image_edit.html', context)