Ejemplo n.º 1
0
def screen_form(request, camera):
    if request.POST and request.POST.get("form", None) == "screen":
        form = PhotoForm(request.POST, request.FILES)
        if form.is_valid():
            camera.screen = form.fields["file"].save("camera_screen", settings.SCREEN_SIZES, "CAM_SCREEN_RESIZE")
            camera.save()
            messages.add_message(request, messages.SUCCESS, _("Screen successfully updated"))
            return
    else:
        form = PhotoForm()

    return dict(screen_form=form, screen=camera.screen)
Ejemplo n.º 2
0
def screen_form(request, camera):
    if request.POST and request.POST.get('form', None) == 'screen':
        form = PhotoForm(request.POST, request.FILES)
        if form.is_valid():
            camera.screen = form.fields['file'].save('camera_screen', settings.SCREEN_SIZES, 'CAM_SCREEN_RESIZE')
            camera.save()
            messages.add_message(request, messages.SUCCESS, _('Screen successfully updated'))
            return
    else:
        form = PhotoForm()

    return dict(screen_form=form, screen=camera.screen)
Ejemplo n.º 3
0
def photo_edit(request, group):
    if request.method != 'POST':
        form = PhotoForm()
    else:
        form = PhotoForm(request.POST, request.FILES)
        if form.is_valid():
            group.photo = form.fields['file'].save('group_photo', settings.GROUP_PHOTO_SIZES, 'GROUP_PHOTO_RESIZE')
            group.save()
            messages.add_message(request, messages.SUCCESS, _('Photo successfully updated'))
            return HttpResponseRedirect(request.path)
    return direct_to_template(request, 'groups/photo_edit.html',
                              dict(form=form, photo=group.photo, group=group)
                              )
Ejemplo n.º 4
0
def avatar_edit(request):
    user = request.user
    if request.method != "POST":
        form = PhotoForm()
    else:
        form = PhotoForm(request.POST, request.FILES)
        if form.is_valid():
            user.avatar = form.fields["file"].save("avatar", settings.AVATAR_SIZES, "AVATAR_RESIZE")
            user.save()

            messages.add_message(request, messages.SUCCESS, _("Avatar successfully updated"))
            return HttpResponseRedirect(request.path)

    return direct_to_template(request, "social/profile/avatar.html", dict(form=form, user=user))
Ejemplo n.º 5
0
def screen_form(request, camera):
    if request.POST and request.POST.get('form', None) == 'screen':
        form = PhotoForm(request.POST, request.FILES)
        if form.is_valid():
            camera.screen = form.fields['file'].save('camera_screen',
                                                     settings.SCREEN_SIZES,
                                                     'CAM_SCREEN_RESIZE')
            camera.save()
            messages.add_message(request, messages.SUCCESS,
                                 _('Screen successfully updated'))
            return
    else:
        form = PhotoForm()

    return dict(screen_form=form, screen=camera.screen)
Ejemplo n.º 6
0
def photo_edit(request, group):
    if request.method != 'POST':
        form = PhotoForm()
    else:
        form = PhotoForm(request.POST, request.FILES)
        if form.is_valid():
            group.photo = form.fields['file'].save('group_photo',
                                                   settings.GROUP_PHOTO_SIZES,
                                                   'GROUP_PHOTO_RESIZE')
            group.save()
            messages.add_message(request, messages.SUCCESS,
                                 _('Photo successfully updated'))
            return HttpResponseRedirect(request.path)
    return direct_to_template(request, 'groups/photo_edit.html',
                              dict(form=form, photo=group.photo, group=group))
Ejemplo n.º 7
0
def avatar_edit(request):
    user = request.user
    if request.method != 'POST':
        form = PhotoForm()
    else:
        form = PhotoForm(request.POST, request.FILES)
        if form.is_valid():
            user.avatar = form.fields['file'].save('avatar',
                                                   settings.AVATAR_SIZES,
                                                   'AVATAR_RESIZE')
            user.save()

            messages.add_message(request, messages.SUCCESS,
                                 _('Avatar successfully updated'))
            return HttpResponseRedirect(request.path)

    return direct_to_template(request, 'social/profile/avatar.html',
                              dict(form=form, user=user))
Ejemplo n.º 8
0
def avatar_edit(request):
    user = request.user
    if request.method != 'POST':
        form = PhotoForm()
    else:
        form = PhotoForm(request.POST, request.FILES)
        if form.is_valid():
            user.avatar = form.fields['file'].save('avatar',
                                                     settings.AVATAR_SIZES, 'AVATAR_RESIZE')
            user.save()

            messages.add_message(request, messages.SUCCESS, _('Avatar successfully updated'))
            return HttpResponseRedirect(request.path)


    return direct_to_template(request, 'social/profile/avatar.html',
                              dict(form=form, user=user)
                              )