예제 #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)
예제 #2
0
파일: views.py 프로젝트: Rudy24/modnoemesto
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)
예제 #3
0
파일: views.py 프로젝트: Rudy24/modnoemesto
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)
                              )
예제 #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))
예제 #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)
예제 #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))
예제 #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))
예제 #8
0
파일: views.py 프로젝트: Rudy24/modnoemesto
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)
                              )