def post(self, request, format=None): action = request.data.get("action", None) if not action: return Response(status=status.HTTP_404_NOT_FOUND) try: if action == 'reset': models.Ledger.objects.all().delete() message = 'Success' elif action == 'generate': if not cc(): response = dict() rc = grc() message = rc.decode('utf-8') else: message = 'Device is already activated' elif action == 'activate': key = request.data.get('key', None) if key: result = cc(key) if not result: message = 'Error' else: device = models.Device.objects.get(pk=1) device.Device_ID = key device.save() message = 'Success' else: message = "Error" else: dev = models.Device.objects.get(pk=1) if action == 'poweroff': dev.action = 1 elif action == 'reboot': dev.action = 2 elif action == 'refresh': dev.action = 3 dev.save() message = "Success" except Exception as e: message = str(e) response = {'message': message} return Response(response)
def post(self, request): if request.is_ajax() and request.user.is_authenticated: if not cc(): response = dict() rc = grc() response['key'] = rc.decode('utf-8') return JsonResponse(response) else: return HttpResponse('Device is already activated') else: raise Http404("Page not found")
def get(self, request, format=None): serial_error = 'You obtained an unauthorized copy of the software. Wifi hotspot customizations is limited. Please contact seller.' sales_format = request.data.get("sales_format", None) info = dict() try: ledger = models.Ledger.objects.all() if sales_format == 'Monthly': info['sales_trend'] = ledger.annotate( Period=TruncMonth('Date')).values('Period').annotate( Sales=Sum('Denomination')).values_list( 'Period', 'Sales') else: info['sales_trend'] = ledger.annotate( Period=TruncDate('Date')).values('Period').annotate( Sales=Sum('Denomination')).values_list( 'Period', 'Sales') except ObjectDoesNotExist: info['sales_trend'] = None connected_count = 0 disconnected_count = 0 clients = models.Clients.objects.all() for client in clients: if client.Connection_Status == 'Connected': connected_count += 1 else: disconnected_count += 1 info['connected_count'] = connected_count info['disconnected_count'] = disconnected_count try: device = models.Device.objects.get(pk=1) cc_res = cc() if cc_res or request.user.is_superuser: info['message'] = None else: info['message'] = serial_error if not cc_res: info['license_status'] = 'Not Activated' info['license'] = None else: info['license_status'] = 'Activated' info['license'] = device.Device_ID return Response(info, status=status.HTTP_200_OK) except ObjectDoesNotExist: info['message'] = serial_error return Response(info, status=status.HTTP_200_OK)
def get(self, request): serial_error = 'You obtained an unauthorized copy of the software. Wifi hotspot customizations is limited. Please contact seller.' action = request.GET.get("action", None) info = dict() if action == 'reset': models.Ledger.objects.all().delete() settings = models.Settings.objects.get(pk=1) try: ledger = models.Ledger.objects.all() sum_ledger = ledger.aggregate(denom=Sum('Denomination')) info['denom'] = sum_ledger['denom'] if sum_ledger['denom'] else 0 except ObjectDoesNotExist: info['denom'] = 0 connected_count = 0 disconnected_count = 0 clients = models.Clients.objects.all() for client in clients: if client.Connection_Status == 'Connected': connected_count += 1 else: disconnected_count += 1 info['connected_count'] = connected_count info['disconnected_count'] = disconnected_count info['count'] = ledger.count() info['hotspot'] = settings.Hotspot_Name info['slot_timeout'] = settings.Slot_Timeout try: device = models.Device.objects.get(pk=1) cc_res = cc() if cc_res or request.user.is_superuser: info['message'] = None else: messages.error(request, serial_error) info['message'] = serial_error if not cc_res: info['license_status'] = 'Not Activated' info['license'] = None else: info['license_status'] = 'Activated' info['license'] = device.Device_ID return render(request, self.template_name, context=info) except ObjectDoesNotExist: return HttpResponse(serial_error)
def post(self, request): if not request.is_ajax and not request.user.is_authenticated: raise Http404("Page not found") ak = request.POST.get('activation_key', None) response = dict() if ak: result = cc(ak) if not result: response['message'] = 'Error' return JsonResponse(response) device = models.Device.objects.get(pk=1) device.Device_ID = ak device.save() response['message'] = 'Success' return JsonResponse(response) else: response['message'] = 'Error' return JsonResponse(response)
def client_check(request): if request.user.is_superuser: return True else: return cc()