Пример #1
0
class ModifyView(View):
    @method_decorator(login_required)
    @method_decorator(check_ownership(InteServiceApplication))
    @method_decorator(check_not_approved(InteServiceApplication))
    def get(self, request):
        app_id = request.GET.get('id')
        app = get_object_or_404(InteServiceApplication, id=app_id)
        form = InteServiceApplicationForm(instance=app)
        return render(
            request, 'integrated_service/form.html', {
                'form': form,
                'app_id': app_id,
                'post_url':
                reverse('integrated_service:modify') + '?id=' + app_id
            })

    @method_decorator(login_required)
    @method_decorator(check_ownership(InteServiceApplication))
    @method_decorator(check_not_approved(InteServiceApplication))
    def post(self, request):
        app_id = request.GET.get('id')
        app = get_object_or_404(InteServiceApplication, id=app_id)
        form = InteServiceApplicationForm(request.POST, instance=app)
        if not form.is_valid():
            return render(
                request, 'integrated_service/form.html', {
                    'form':
                    form,
                    'app_id':
                    app_id,
                    'post_url':
                    reverse('integrated_service:modify') + '?id=' + app_id
                })
        form.save()
        return HttpResponseRedirect(reverse('integrated_service:manage'))
Пример #2
0
class ModifyView(View):
    @method_decorator(login_required)
    @method_decorator(check_ownership(ExhibitApplication))
    @method_decorator(check_not_approved(ExhibitApplication))
    def get(self, request):
        app_id = request.GET.get('id')
        app = get_object_or_404(ExhibitApplication, id=app_id)
        form = ExhibitApplicationForm(instance=app)
        return render(request, 'campus_field/exhibit/form.html',
                {'form': form, 'app_id': app_id,
                 'post_url': \
                     reverse('exhibit:modify')+'?id='+app_id})

    @method_decorator(login_required)
    @method_decorator(check_ownership(ExhibitApplication))
    @method_decorator(check_not_approved(ExhibitApplication))
    def post(self, request):
        app_id = request.GET.get('id')
        app = get_object_or_404(ExhibitApplication, id=app_id)
        form = ExhibitApplicationForm(request.POST,
                                      request.FILES,
                                      instance=app)
        if not form.is_valid():
            return render(request, 'campus_field/exhibit/form.html',
                {'form': form, 'app_id': app_id,
                 'post_url': \
                     reverse('exhibit:modify')+'?id='+app_id})
        form.save()
        return HttpResponseRedirect(reverse('exhibit:manage'))