Esempio n. 1
0
 def get_context_data(self, **kwargs):
     if self.request.user.role != USER_ROLES[2][0]:
         raise PermissionDenied("You don't have an acces to this page")
     context = super(ProcessingListView, self).get_context_data(**kwargs)
     context['data'] = ProfileData().processing()
     context['locked'] = LockTable.objects.filter(locked=True)
     return context
Esempio n. 2
0
def processing_list(request):
    activate(request.user.extended.language)
    if not request.user.is_authenticated or request.user.extended.role != USER_ROLES[2][0]:
        return HttpResponse('<h1>Unknown error</h1>')
    return render(request, "tools/ProcessingRequests.html", {
        'data': ProfileData().processing(), 'locked': LockTable.objects.filter(locked=True)
    })
Esempio n. 3
0
    def post(self, request):
        action = request.data.get('action')

        if action == 'between':
            data = ProfileData().get_statistic(
                float(request.data['date1']) if request.data.get('date1') else None,
                float(request.data['date2']) if request.data.get('date2') else None,
                request.data.get('name')
            )
        elif action == 'around' and 'date' in request.POST:
            data = ProfileData().get_statistic_around(
                float(request.data['date']),
                int(request.data['interval']) if request.data.get('interval') else None
            )
        else:
            raise exceptions.APIException(str(UNKNOWN_ERROR))
        return Response({'data': data}, template_name='tools/CallStatistic.html')
Esempio n. 4
0
def call_statistic(request):
    activate(request.user.extended.language)
    if not request.user.is_authenticated or request.method != 'POST' or request.user.extended.role != USER_ROLES[2][0]:
        return HttpResponse('<h1>Unknown error</h1>')
    action = request.POST.get('action')
    data = None
    if action == 'between':
        date1 = None
        if 'date1' in request.POST:
            date1 = float(request.POST['date1'])
        date2 = None
        if 'date2' in request.POST:
            date2 = float(request.POST['date2'])
        data = ProfileData().get_statistic(date1, date2, request.POST.get('name'))
    elif action == 'around' and 'date' in request.POST:
        if 'interval' in request.POST:
            data = ProfileData().get_statistic_around(float(request.POST['date']), int(request.POST['interval']))
        else:
            data = ProfileData().get_statistic_around(float(request.POST['date']))
    return render(request, "tools/CallStatistic.html", {'data': data})