add command to process location data
This commit is contained in:
		@@ -1,4 +1,8 @@
 | 
			
		||||
from django.contrib import admin
 | 
			
		||||
from django.conf.urls import url
 | 
			
		||||
from django.contrib import admin, messages
 | 
			
		||||
from django.shortcuts import redirect
 | 
			
		||||
from django.template.response import TemplateResponse
 | 
			
		||||
 | 
			
		||||
from .models import *
 | 
			
		||||
from django import forms
 | 
			
		||||
from django.core.exceptions import ValidationError
 | 
			
		||||
@@ -33,6 +37,16 @@ class ClientAdmin(admin.ModelAdmin):
 | 
			
		||||
 | 
			
		||||
@admin.register(LocationData)
 | 
			
		||||
class LocationDataAdmin(admin.ModelAdmin):
 | 
			
		||||
    def get_urls(self):
 | 
			
		||||
        urls = super().get_urls()
 | 
			
		||||
        my_urls = [
 | 
			
		||||
            url(r'^process_locationdata/$', self.admin_site.admin_view(self.process_locationdata), name='process_locationdata'),
 | 
			
		||||
        ]
 | 
			
		||||
        return my_urls + urls
 | 
			
		||||
 | 
			
		||||
    def process_locationdata(self, request):
 | 
			
		||||
        messages.success(request, '2739847239847298374982374 Items prozessiert.')
 | 
			
		||||
        return redirect('admin:billard_locationdata_changelist')
 | 
			
		||||
    list_display = ('client_id', 'desk_no', 'tst', 'on_off', 'processed', 'error_msg')
 | 
			
		||||
    fields = ['client_id', 'desk_no', 'tst', 'on_off', 'processed', 'error_msg']
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,10 @@
 | 
			
		||||
{% extends "admin/change_list.html" %}
 | 
			
		||||
{% load i18n admin_urls static admin_list %}
 | 
			
		||||
{% block object-tools-items %}
 | 
			
		||||
<li>
 | 
			
		||||
  <a href="{% url 'admin:process_locationdata' %}">
 | 
			
		||||
      LD Verarbeiten
 | 
			
		||||
  </a>
 | 
			
		||||
</li>
 | 
			
		||||
{{ block.super }}
 | 
			
		||||
{% endblock %}
 | 
			
		||||
@@ -4,7 +4,7 @@ from rest_framework import routers
 | 
			
		||||
from billard import views
 | 
			
		||||
 | 
			
		||||
router = routers.DefaultRouter()
 | 
			
		||||
router.register(r'location_data', views.LocationDataViewSet)
 | 
			
		||||
router.register(r'locationdata', views.LocationDataViewSet)
 | 
			
		||||
 | 
			
		||||
app_name = 'billard'
 | 
			
		||||
urlpatterns = [
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,5 @@
 | 
			
		||||
import ast
 | 
			
		||||
import logging
 | 
			
		||||
 | 
			
		||||
from billard.serializers import LocationDataSerializer
 | 
			
		||||
from billard.models import LocationData, Location, Client, Accounting
 | 
			
		||||
@@ -13,6 +14,9 @@ from django.utils.decorators import method_decorator
 | 
			
		||||
from django.utils import timezone
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
log = logging.getLogger(__name__)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class LocationIndexView(generic.ListView):
 | 
			
		||||
    template_name = 'billard/location_index.html'
 | 
			
		||||
    context_object_name = 'location_list'
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,7 @@ from datetime import datetime
 | 
			
		||||
import requests
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
url = 'http://127.0.0.1:8000/billard/api/v1/location_data/'
 | 
			
		||||
url = 'http://127.0.0.1:8000/billard/api/v1/locationdata/'
 | 
			
		||||
client_id = '28a34fa1-7b62-4b78-8d2a-ada4db4ac6ea'
 | 
			
		||||
token = '588d0f4c4b8b90b507e6d5c0ea26f0e28b021262'
 | 
			
		||||
default_desk_id = 2
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user