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)
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)
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) )
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))
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))
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))
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) )