register device form and view
This commit is contained in:
parent
d074818447
commit
92354201af
5 changed files with 69 additions and 10 deletions
|
|
@ -8,7 +8,8 @@
|
||||||
"Reparateure",
|
"Reparateure",
|
||||||
"reparateur_id",
|
"reparateur_id",
|
||||||
"organisator_id",
|
"organisator_id",
|
||||||
"Reparateurs"
|
"Reparateurs",
|
||||||
|
"repapp"
|
||||||
],
|
],
|
||||||
"ignoreWords": [],
|
"ignoreWords": [],
|
||||||
"import": []
|
"import": []
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,9 @@
|
||||||
<ul class="list-group">
|
<ul class="list-group">
|
||||||
{% for cafe in object_list %}
|
{% for cafe in object_list %}
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
|
<a href="{% url 'register_device' cafe.id %}">
|
||||||
<button type="button" class="btn btn-primary">Repair-Café am {{ cafe.event_date|date }}, {{ cafe.location }}</button>
|
<button type="button" class="btn btn-primary">Repair-Café am {{ cafe.event_date|date }}, {{ cafe.location }}</button>
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<li class="list-group-item">Es gibt keine geplanten Repair-Cafés.</li>
|
<li class="list-group-item">Es gibt keine geplanten Repair-Cafés.</li>
|
||||||
|
|
|
||||||
30
rc_hip/repapp/templates/repapp/register_device.html
Normal file
30
rc_hip/repapp/templates/repapp/register_device.html
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
{% extends "repapp/base.html" %}
|
||||||
|
|
||||||
|
{% block title %}- Gerät anmelden{% endblock title %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<form action="{% url 'register_device' cafe.id %}" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="email_address" class="form-label">eMail Adresse</label>
|
||||||
|
<input type="text" class="form-control" id="email_address" name="email_address" aria-describedby="email_help">
|
||||||
|
<div id="email_help" class="form-text">Diese eMail-Adresse wird für Aktualisierungen zur Anfrage verwendet.</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="device" class="form-label">Gerätebezeichnung</label>
|
||||||
|
<input type="text" class="form-control" id="device" name="device" aria-describedby="device_help">
|
||||||
|
<div id="device_help" class="form-text">Bitte geben Sie den Hersteller und die Gerätebezeichnung an.</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="issue" class="form-label">Fehlerbeschreibung</label>
|
||||||
|
<textarea rows="6" cols="60" class="form-control" id="issue" name="issue" aria-describedby="issue_help"></textarea>
|
||||||
|
<div id="issue_help" class="form-text">Beschreiben Sie hier das Problem ihres Gerätes.</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3 form-check">
|
||||||
|
<input type="checkbox" class="form-check-input" id="follow_up" name="follow_up" aria-describedby="follow_up_help">
|
||||||
|
<label class="form-check-label" for="follow_up">Folgetermin</label>
|
||||||
|
<div id="follow_up_help" class="form-text">Klicken Sie dieses Kästchen an wenn sie mit diesem Gerät bereits bei einem Repair-Café waren.</div>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">Absenden</button>
|
||||||
|
</form>
|
||||||
|
{% endblock content %}
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
|
"""
|
||||||
|
Urls of RepApp.
|
||||||
|
"""
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", views.IndexView.as_view(), name="index"),
|
path("", views.IndexView.as_view(), name="index"),
|
||||||
|
path("<int:cafe_id>/", views.register_device, name="register_device"),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,37 @@
|
||||||
from django.shortcuts import render
|
"""
|
||||||
from django.http import HttpResponse
|
Views of RepApp.
|
||||||
|
"""
|
||||||
|
import datetime
|
||||||
|
from django.shortcuts import get_object_or_404, render
|
||||||
|
from django.http import HttpResponse, HttpResponseRedirect
|
||||||
from django.views import generic
|
from django.views import generic
|
||||||
from .models import Cafe
|
from .models import Cafe, Guest, Device
|
||||||
|
|
||||||
|
|
||||||
def index(request):
|
|
||||||
return HttpResponse("Hello from RepApp.")
|
|
||||||
|
|
||||||
|
|
||||||
class IndexView(generic.ListView):
|
class IndexView(generic.ListView):
|
||||||
|
"""
|
||||||
|
The IndexView lists all future Repair-Cafés.
|
||||||
|
"""
|
||||||
template_name = "repapp/index.html"
|
template_name = "repapp/index.html"
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return Cafe.objects.all()
|
return Cafe.objects.filter(event_date__gte=datetime.date.today())
|
||||||
|
|
||||||
|
|
||||||
|
def register_device(request, cafe_id):
|
||||||
|
if request.method == "POST":
|
||||||
|
mail = request.POST.get('email_address', '')
|
||||||
|
device = request.POST.get('device', '')
|
||||||
|
issue = request.POST.get('issue', ''),
|
||||||
|
follow_up = request.POST.get('follow_up', 'false') == 'on'
|
||||||
|
return HttpResponse(f"{mail} {device} {issue} {follow_up}")
|
||||||
|
# return HttpResponseRedirect(reverse("polls:results", args=(question.id,)))
|
||||||
|
else:
|
||||||
|
cafe = get_object_or_404(Cafe, pk=cafe_id)
|
||||||
|
return render(
|
||||||
|
request,
|
||||||
|
"repapp/register_device.html",
|
||||||
|
{
|
||||||
|
"cafe": cafe,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
|
||||||
Reference in a new issue