Пример #1
0
    def post(self, request, pk):
        company = CompanyContainer(request.user)
        rq = RequestUtil()
        i = rq.get_event_info(request)
        context = {
            'company': company.get_company(),
            'event': company.get_event(pk),
            'countries': HomeUtil.get_countries(),
            'states': HomeUtil.get_states(),
            'tab': 'events',
        }
        if i:

            try:
                with transaction.atomic():
                    if company.edit_event(pk, i):
                        return redirect('event:company_events')
                    else:
                        raise IntegrityError
            except IntegrityError:
                context['event'] = i
                context['errors'] = company.get_form().errors

        else:
            context['event'] = rq.get_info()
            context['errors'] = rq.get_errors()

        return render(request, self.template_name, context)
Пример #2
0
 def get(self, request, pk):
     company = CompanyContainer(request.user)
     context = {
         'event': company.get_event(pk),
         'company': company.get_company(),
         'tab': 'events',
     }
     return render(request, self.template_name, context)
Пример #3
0
def detail_view(request, pk):

    if request.method == 'GET':
        company = CompanyContainer(request.user)
        context = {
            'event': company.get_event(pk),
            'company': company.get_company(),
            'tab': 'events',
        }
        return render(request, 'event/detail.html', context)

    raise Http404
Пример #4
0
def close_event(request, pk):

    if request.method == 'GET':
        company = CompanyContainer(request.user)
        context = {
            'event': company.get_event(pk),
            'company': company.get_company(),
            'tab': 'events',
        }
        try:
            with transaction.atomic():
                if company.close_event(pk):
                    return HttpResponse('success', status=200)
                else:
                    raise IntegrityError
        except IntegrityError:
            return HttpResponse(str(company.get_errors()), status=400)

        return render(request, 'event/detail.html', context)

    raise Http404