rebuild location index and detail view
This commit is contained in:
parent
9186ed2083
commit
5477a26cbb
21
billard/migrations/0022_auto_20170427_0835.py
Normal file
21
billard/migrations/0022_auto_20170427_0835.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11 on 2017-04-27 08:35
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('billard', '0021_accounting_account_user'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='client',
|
||||||
|
name='location',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='clients', to='billard.Location', verbose_name='Standort'),
|
||||||
|
),
|
||||||
|
]
|
@ -48,7 +48,7 @@ class Location(models.Model):
|
|||||||
|
|
||||||
class Client(models.Model):
|
class Client(models.Model):
|
||||||
uuid = models.UUIDField(unique=True, default=uuid.uuid4, verbose_name="Identifier")
|
uuid = models.UUIDField(unique=True, default=uuid.uuid4, verbose_name="Identifier")
|
||||||
location = models.ForeignKey(Location, verbose_name="Standort")
|
location = models.ForeignKey(Location, related_name="clients", verbose_name="Standort")
|
||||||
report_user = models.ForeignKey(User, blank=True, null=True, verbose_name="Reporting Benutzer", related_name='reporting_clients')
|
report_user = models.ForeignKey(User, blank=True, null=True, verbose_name="Reporting Benutzer", related_name='reporting_clients')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -28,9 +28,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="navbar" class="collapse navbar-collapse">
|
<div id="navbar" class="collapse navbar-collapse">
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li class="{% ifequal request.path '/billard/' %}active{% endifequal %}"><a href="{% url "billard:location_list" %}">Standorte</a></li>
|
<li class="{% ifequal request.path '/billard/' %}active{% endifequal %}"><a href="{% url "billard:location_index" %}">Standorte</a></li>
|
||||||
{% if perms.billard.change_accounting %}
|
{% if perms.billard.change_accounting %}
|
||||||
<li class="{% ifequal request.path '/billard/accounting' %}active{% endifequal %}"><a href="{% url "billard:location_list" %}">Abrechnung</a></li>
|
<li class="{% ifequal request.path '/billard/accounting' %}active{% endifequal %}"><a href="{% url "billard:location_index" %}">Abrechnung</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if user.is_superuser %}
|
{% if user.is_superuser %}
|
||||||
<li class="{% ifequal request.path '/logout/' %}active{% endifequal %}"><a href="/admin/">Administration</a></li>
|
<li class="{% ifequal request.path '/logout/' %}active{% endifequal %}"><a href="/admin/">Administration</a></li>
|
||||||
|
@ -16,12 +16,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div id="desk_data">
|
<div id="desk_data">
|
||||||
{% include 'billard/index_ajax.html' %}
|
{% include 'billard/index_ajax.html' %}
|
||||||
</div>
|
</div>
|
||||||
<div id="modal-wrapper">
|
<div id="modal-wrapper">
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var interval;
|
var interval;
|
||||||
|
25
billard/templates/billard/location_detail.html
Normal file
25
billard/templates/billard/location_detail.html
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{% extends 'billard/base.html' %}
|
||||||
|
|
||||||
|
{% block title %}Standort{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div id="desk_data">
|
||||||
|
{% include 'billard/location_detail_ajax.html' %}
|
||||||
|
</div>
|
||||||
|
<div id="modal-wrapper">
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
<script type="text/javascript">
|
||||||
|
var interval;
|
||||||
|
$(document).ready(function() {
|
||||||
|
$.ajaxSetup({ cache: false });
|
||||||
|
interval = window.setInterval(refresh_page, 1000);
|
||||||
|
});
|
||||||
|
|
||||||
|
function refresh_page() {
|
||||||
|
$('#desk_data').load('#');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
12
billard/templates/billard/location_detail_ajax.html
Normal file
12
billard/templates/billard/location_detail_ajax.html
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{% load display_client %}
|
||||||
|
{% if location.clients.all %}
|
||||||
|
{% for cli in location.clients.all %}
|
||||||
|
{% for i in "12345678" %}
|
||||||
|
{{ cli|display_client:i }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="col-md-12 alert alert-danger">Keine Tische angelegt!</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
@ -1,10 +1,11 @@
|
|||||||
{% extends 'billard/base.html' %}
|
{% extends 'billard/base.html' %}
|
||||||
|
|
||||||
{% block title %}Location List{% endblock %}
|
{% block title %}Standortliste{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% if location_list %}
|
{% if location_list %}
|
||||||
|
<h2>Bitte Standort auswählen:</h2>
|
||||||
<table class="table table-hover">
|
<table class="table table-hover">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Code</th>
|
<th>Code</th>
|
||||||
@ -15,11 +16,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% for loc in location_list %}
|
{% for loc in location_list %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{% url 'billard:location_detail' loc.id %}">{{ loc.code }}</a></td>
|
<td><a href="{% url 'billard:location_detail' loc.id %}">{{ loc.code|default_if_none:"" }}</a></td>
|
||||||
<td><a href="{% url 'billard:location_detail' loc.id %}">{{ loc.name }}</a></td>
|
<td><a href="{% url 'billard:location_detail' loc.id %}">{{ loc.name|default_if_none:"" }}</a></td>
|
||||||
<td><a href="{% url 'billard:location_detail' loc.id %}">{{ loc.street }}</a></td>
|
<td><a href="{% url 'billard:location_detail' loc.id %}">{{ loc.street|default_if_none:"" }}</a></td>
|
||||||
<td><a href="{% url 'billard:location_detail' loc.id %}">{{ loc.plz }}</a></td>
|
<td><a href="{% url 'billard:location_detail' loc.id %}">{{ loc.plz|default_if_none:"" }}</a></td>
|
||||||
<td><a href="{% url 'billard:location_detail' loc.id %}">{{ loc.city }}</a></td>
|
<td><a href="{% url 'billard:location_detail' loc.id %}">{{ loc.city|default_if_none:"" }}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
@ -9,7 +9,7 @@ router.register(r'location_data', views.LocationDataViewSet)
|
|||||||
app_name = 'billard'
|
app_name = 'billard'
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# ex. /billard/
|
# ex. /billard/
|
||||||
url(r'^$', login_required(views.LocationListView.as_view()), name='location_list'),
|
url(r'^$', login_required(views.LocationIndexView.as_view()), name='location_index'),
|
||||||
# ex. /billard/1/
|
# ex. /billard/1/
|
||||||
url(r'^(?P<pk>[0-9]+)/$', login_required(views.LocationDetailView.as_view()), name='location_detail'),
|
url(r'^(?P<pk>[0-9]+)/$', login_required(views.LocationDetailView.as_view()), name='location_detail'),
|
||||||
# ex. /billard/1/accounting/
|
# ex. /billard/1/accounting/
|
||||||
@ -21,7 +21,7 @@ urlpatterns = [
|
|||||||
#url(r'api/v1/', include(router.urls)),
|
#url(r'api/v1/', include(router.urls)),
|
||||||
#url(r'process_locationdata', views.process_locationdata, name='process_locationdata'),
|
#url(r'process_locationdata', views.process_locationdata, name='process_locationdata'),
|
||||||
#url(r'^accounting/$', views.AccountingView.as_view(), name='accounting'),
|
#url(r'^accounting/$', views.AccountingView.as_view(), name='accounting'),
|
||||||
#url(r'accountmodal$', views.accountmodalview, name='accountmodal'),
|
url(r'^accountmodal$', views.accountmodalview, name='accountmodal'),
|
||||||
#url(r'accoutmodal/confirm/(?P<pk>[0-9]+)$', views.accountmodalconfirmview, name="accountmodalconfirm")
|
url(r'^accoutmodal/confirm/(?P<pk>[0-9]+)$', views.accountmodalconfirmview, name="accountmodalconfirm")
|
||||||
# (?P<pk>[0-9]+)
|
# (?P<pk>[0-9]+)
|
||||||
]
|
]
|
||||||
|
@ -8,10 +8,11 @@ from django.views.generic.detail import DetailView
|
|||||||
from django.contrib.auth.decorators import login_required, permission_required
|
from django.contrib.auth.decorators import login_required, permission_required
|
||||||
from django.db.models import Min, Sum
|
from django.db.models import Min, Sum
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
from django.utils.decorators import method_decorator
|
||||||
|
|
||||||
|
|
||||||
class LocationListView(generic.ListView):
|
class LocationIndexView(generic.ListView):
|
||||||
template_name = 'billard/location_list.html'
|
template_name = 'billard/location_index.html'
|
||||||
context_object_name = 'location_list'
|
context_object_name = 'location_list'
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
@ -19,13 +20,26 @@ class LocationListView(generic.ListView):
|
|||||||
return Location.objects.filter(users__id=self.request.user.id).order_by('code')
|
return Location.objects.filter(users__id=self.request.user.id).order_by('code')
|
||||||
|
|
||||||
|
|
||||||
class LocationDetailView(generic.ListView):
|
class LocationDetailView(generic.DetailView):
|
||||||
template_name = 'billard/location_list.html'
|
model = Location
|
||||||
context_object_name = 'location_list'
|
template_name = 'billard/location_detail.html'
|
||||||
|
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
if request.is_ajax():
|
||||||
|
context = {
|
||||||
|
'location': self.get_object(),
|
||||||
|
}
|
||||||
|
return render(request, template_name='billard/location_detail_ajax.html', context=context)
|
||||||
|
return super(LocationDetailView, self).dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
@method_decorator(login_required, name='dispatch')
|
||||||
|
class AccountingView(generic.ListView):
|
||||||
|
template_name = 'billard/accounting.html'
|
||||||
|
context_object_name = 'accounting'
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
"""Return the last five published questions."""
|
return Accounting.objects.filter(billed=False).exclude(time_to__isnull=True)
|
||||||
return Location.objects.filter(users__id=self.request.user.id).order_by('code')
|
|
||||||
|
|
||||||
|
|
||||||
# TODO OLD CODE, CLEAN UP
|
# TODO OLD CODE, CLEAN UP
|
||||||
@ -164,18 +178,6 @@ def index(request):
|
|||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
|
||||||
#@login_required
|
|
||||||
#@permission_required('billard.change_accounting')
|
|
||||||
class AccountingView(generic.ListView):
|
|
||||||
template_name = 'billard/accounting.html'
|
|
||||||
context_object_name = 'accounting'
|
|
||||||
|
|
||||||
def get_queryset(self):
|
|
||||||
return Accounting.objects.filter(billed=False).exclude(time_to__isnull=True)\
|
|
||||||
#.\
|
|
||||||
#filter(desk__client__location_id=loc).order_by('-time_from')
|
|
||||||
|
|
||||||
|
|
||||||
def process_locationdata(request):
|
def process_locationdata(request):
|
||||||
process_location_data()
|
process_location_data()
|
||||||
return HttpResponse('DONE')
|
return HttpResponse('DONE')
|
||||||
|
Loading…
Reference in New Issue
Block a user