Generalize pretixdroid settings UI

This commit is contained in:
Raphael Michel
2018-01-06 22:45:32 +01:00
parent f054e700a2
commit f65f166ea6
9 changed files with 148 additions and 58 deletions

View File

@@ -9,15 +9,16 @@
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="294.15625"
height="149.59375"
width="600"
height="400"
id="svg2"
version="1.1"
inkscape:version="0.91 r13725"
inkscape:version="0.92.1 r"
sodipodi:docname="logo.svg"
inkscape:export-filename="/home/raphael/proj/pretix/pretix/logo_draft.png"
inkscape:export-xdpi="88.529999"
inkscape:export-ydpi="88.529999">
inkscape:export-filename="/tmp/LOGO.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
viewBox="0 0 562.50001 375.00002">
<defs
id="defs4" />
<sodipodi:namedview
@@ -28,14 +29,14 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.9899495"
inkscape:cx="134.70089"
inkscape:cy="277.43904"
inkscape:cx="133.36756"
inkscape:cy="276.10571"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="636"
inkscape:window-width="1916"
inkscape:window-height="1041"
inkscape:window-x="3200"
inkscape:window-x="1920"
inkscape:window-y="18"
inkscape:window-maximized="0"
fit-margin-top="20"
@@ -58,11 +59,14 @@
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-257.78125,-548.75)">
transform="translate(-259.03125,-322.09374)">
<path
style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:#3b1c4a;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;enable-background:accumulate"
d="M 20 20 L 20 54.09375 C 31.43679 54.09375 40.71875 63.37571 40.71875 74.8125 C 40.71875 86.24928 31.43679 95.5 20 95.5 L 20 129.59375 L 166.6875 129.59375 L 166.6875 120.09375 L 169.6875 120.09375 L 169.6875 129.59375 L 274.15625 129.59375 L 274.15625 95.5 C 274.14575 95.50002 274.1354 95.5 274.125 95.5 C 262.68822 95.5 253.40625 86.24928 253.40625 74.8125 C 253.40625 63.37571 262.68822 54.09375 274.125 54.09375 C 274.1355 54.09375 274.14585 54.09373 274.15625 54.09375 L 274.15625 20 L 169.6875 20 L 169.6875 29.09375 L 166.6875 29.09375 L 166.6875 20 L 20 20 z M 166.6875 36.09375 L 169.6875 36.09375 L 169.6875 50.09375 L 166.6875 50.09375 L 166.6875 36.09375 z M 208.12891 48.927734 C 210.91958 48.927734 213.15234 50.855474 213.15234 53.240234 C 213.15234 55.624994 210.91958 57.603516 208.12891 57.603516 C 205.38897 57.603516 203.15625 55.624994 203.15625 53.240234 C 203.15625 50.855474 205.38897 48.927734 208.12891 48.927734 z M 194.90039 53.138672 L 194.90039 61.15625 L 198.85938 61.15625 L 198.85938 67.447266 L 194.90039 67.447266 L 194.90039 79.726562 C 194.90039 81.756152 195.61054 82.517578 197.03125 82.517578 C 197.7416 82.517578 198.09828 82.415768 198.85938 82.111328 L 198.85938 88.046875 C 198.14902 88.452785 196.47277 89.011719 194.24023 89.011719 C 188.10074 89.011719 185.25977 85.257843 185.25977 80.539062 L 185.25977 67.447266 L 182.41797 67.447266 L 182.41797 61.15625 L 185.25977 61.15625 L 185.25977 55.574219 L 194.90039 53.138672 z M 166.6875 57.09375 L 169.6875 57.09375 L 169.6875 71.09375 L 166.6875 71.09375 L 166.6875 57.09375 z M 92.119141 60.648438 C 100.59265 60.648438 106.32617 65.164126 106.32617 74.753906 C 106.32617 83.379636 101.30281 88.859375 94.25 88.859375 C 92.52486 88.859375 91.102928 88.656085 90.392578 88.453125 L 90.392578 99.414062 L 80.751953 99.414062 L 80.751953 62.728516 C 83.339673 61.510766 86.842221 60.648435 92.119141 60.648438 z M 141.98242 60.648438 C 150.55741 60.648438 154.61678 66.583801 154.10938 75.869141 L 138.17773 78.103516 C 138.78661 81.046406 140.35834 82.517578 143.85938 82.517578 C 147.1067 82.517578 149.64383 81.806022 151.16602 81.044922 L 153.29688 86.931641 C 150.91212 88.098651 147.71654 89.011719 142.64258 89.011719 C 133.71241 89.011719 128.99414 82.973726 128.99414 74.753906 C 128.99414 66.534096 133.40743 60.648438 141.98242 60.648438 z M 124.06055 60.654297 C 124.95335 60.667874 125.8885 60.69926 126.86523 60.75 L 125.18945 67.447266 C 123.41356 66.584696 121.68841 66.533574 120.41992 66.990234 L 120.41992 88.503906 L 110.7793 88.503906 L 110.7793 62.728516 C 113.57632 61.352202 117.81096 60.559256 124.06055 60.654297 z M 203.30859 61.15625 L 212.94922 61.15625 L 212.94922 88.503906 L 203.30859 88.503906 L 203.30859 61.15625 z M 216.54297 61.15625 L 226.58984 61.15625 L 229.88867 68.005859 L 229.99023 68.005859 L 233.5918 61.15625 L 242.57227 61.15625 L 234.60742 73.789062 L 243.33398 88.503906 L 232.67969 88.503906 L 229.17773 80.943359 L 229.07617 80.943359 L 225.42383 88.503906 L 215.68164 88.503906 L 224.25586 74.398438 L 216.54297 61.15625 z M 141.57617 66.179688 C 138.73475 66.179688 137.16236 68.765636 137.4668 73.535156 L 145.23047 72.369141 C 145.23047 68.208501 144.01167 66.179687 141.57617 66.179688 z M 92.068359 66.279297 C 91.358009 66.279297 90.849228 66.380983 90.392578 66.533203 L 90.392578 82.972656 C 90.747748 83.124866 91.256406 83.226562 91.916016 83.226562 C 95.366316 83.226562 96.787109 80.386048 96.787109 74.804688 C 96.787109 69.071117 95.569389 66.279297 92.068359 66.279297 z M 166.6875 78.09375 L 169.6875 78.09375 L 169.6875 92.09375 L 166.6875 92.09375 L 166.6875 78.09375 z M 166.6875 99.09375 L 169.6875 99.09375 L 169.6875 113.09375 L 166.6875 113.09375 L 166.6875 99.09375 z "
transform="translate(257.78125,548.75)"
id="rect3888" />
style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:#3b1c4a;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.91138947;marker:none;enable-background:accumulate"
d="m 297.38548,404.85558 v 65.16643 c 21.86016,0 39.6016,17.74144 39.6016,39.60159 0,21.86015 -17.74144,39.54187 -39.6016,39.54187 v 65.16644 h 280.37693 v -18.1582 h 5.73417 v 18.1582 h 199.68046 v -65.16644 c -0.02,4e-5 -0.0397,0 -0.0596,0 -21.86015,0 -39.6016,-17.68172 -39.6016,-39.54187 0,-21.86015 17.74145,-39.60159 39.6016,-39.60159 0.02,0 0.0397,-4e-5 0.0596,0 V 404.85558 H 583.49658 v 17.38169 h -5.73417 V 404.85558 Z M 577.76241,435.617 h 5.73417 v 26.75945 h -5.73417 z m 79.21068,24.53074 c 5.33405,0 9.60172,3.68466 9.60172,8.24287 0,4.5582 -4.26767,8.33993 -9.60172,8.33993 -5.2371,0 -9.50469,-3.78173 -9.50469,-8.33993 0,-4.55821 4.26759,-8.24287 9.50469,-8.24287 z m -25.28486,8.04874 v 15.32472 h 7.56717 v 12.02458 h -7.56717 v 23.47051 c 0,3.87934 1.35737,5.33473 4.0729,5.33473 1.35775,0 2.03951,-0.19461 3.49427,-0.77651 v 11.34514 c -1.35777,0.77585 -4.56174,1.84419 -8.829,1.84419 -11.73495,0 -17.16515,-7.17511 -17.16515,-16.19455 v -25.02351 h -5.43179 V 483.5212 h 5.43179 v -10.66944 z m -53.92582,7.5597 h 5.73417 v 26.75945 h -5.73417 z m -142.52917,6.79439 c 16.19618,0 27.15517,8.63124 27.15517,26.96104 0,16.48713 -9.6016,26.96105 -23.08227,26.96105 -3.29741,0 -6.01528,-0.38857 -7.37304,-0.77651 v 20.95062 H 413.50612 V 486.5264 c 4.94614,-2.32759 11.64087,-3.97583 21.72712,-3.97583 z m 95.30815,0 c 16.39014,0 24.14917,11.34479 23.17933,29.09269 l -30.45158,4.27076 c 1.1638,5.62501 4.16799,8.437 10.85985,8.437 6.20689,0 11.05633,-1.36007 13.96583,-2.81482 l 4.0729,11.2518 c -4.5582,2.23062 -10.6662,3.97584 -20.36451,3.97584 -17.06903,0 -26.08749,-11.54096 -26.08749,-27.25223 0,-15.71126 8.43552,-26.96104 24.82567,-26.96104 z m -34.25568,0.0113 c 1.70649,0.026 3.49392,0.0859 5.36084,0.18292 l -3.20307,12.80108 c -3.39442,-1.6487 -6.69185,-1.74642 -9.11643,-0.87356 v 41.121 h -18.42698 v -49.2668 c 5.3462,-2.63068 13.44024,-4.1463 25.38564,-3.96465 z m 151.47387,0.95943 h 18.42699 v 52.27202 h -18.42699 z m 25.29605,0 h 19.20348 l 6.30535,13.09227 h 0.19412 l 6.884,-13.09227 h 17.16517 l -15.22393,24.14622 16.67986,28.1258 h -20.3645 l -6.69361,-14.45115 h -0.19412 l -6.98104,14.45115 h -18.62112 l 16.38867,-26.96104 z m -143.29075,9.60175 c -5.43106,0 -8.43651,4.94275 -7.85461,14.05916 l 14.8394,-2.22871 c 0,-7.9526 -2.3296,-11.83045 -6.98479,-11.83045 z m -94.6287,0.19038 c -1.35776,0 -2.33024,0.19437 -3.20308,0.48532 v 31.4222 c 0.67888,0.29093 1.65112,0.48531 2.91189,0.48531 6.59487,0 9.31055,-5.42933 9.31055,-16.09748 0,-10.95908 -2.32753,-16.29535 -9.01936,-16.29535 z m 142.62623,22.58194 h 5.73417 v 26.75946 h -5.73417 z m 0,40.13918 h 5.73417 v 26.75946 h -5.73417 z"
id="rect3888"
inkscape:connector-curvature="0"
inkscape:export-filename="/tmp/LOGO.png"
inkscape:export-xdpi="88"
inkscape:export-ydpi="88" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@@ -6,14 +6,14 @@ from pretix import __version__ as version
class PretixdroidApp(AppConfig):
name = 'pretix.plugins.pretixdroid'
verbose_name = _("pretixdroid API")
verbose_name = _("Check-in device API")
class PretixPluginMeta:
name = _("pretixdroid API")
name = _("Check-in device API")
author = _("the pretix team")
version = version
visible = True
description = _("This plugin allows you to use the pretixdroid Android app for your event.")
description = _("This plugin allows you to use the pretixdroid and pretixdesk apps for your event.")
def ready(self):
from . import signals # NOQA

View File

@@ -6,11 +6,12 @@ from pretix.plugins.pretixdroid.models import AppConfiguration
class AppConfigurationForm(forms.ModelForm):
class Meta:
model = AppConfiguration
fields = ('all_items', 'items', 'list', 'show_info', 'allow_search')
fields = ('all_items', 'items', 'list', 'show_info', 'allow_search', 'app')
widgets = {
'items': forms.CheckboxSelectMultiple(attrs={
'data-inverse-dependency': '#id_all_items'
}),
'app': forms.RadioSelect
}
def __init__(self, **kwargs):

View File

@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2018-01-06 21:22
from __future__ import unicode_literals
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('pretixdroid', '0004_auto_20171124_1657'),
]
operations = [
migrations.AddField(
model_name='appconfiguration',
name='app',
field=models.CharField(choices=[('pretixdroid', 'pretixdroid for Android smartphones'), ('pretixdesk', 'pretixdesk for desktop computers')], default='pretixdroid', max_length=190, verbose_name='Scan software'),
),
migrations.AlterField(
model_name='appconfiguration',
name='allow_search',
field=models.BooleanField(default=True, help_text='If disabled, the device can not search for attendees by name. pretixdroid 1.6 or pretixdesk only.', verbose_name='Search allowed'),
),
migrations.AlterField(
model_name='appconfiguration',
name='list',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='pretixbase.CheckinList', verbose_name='Check-in list'),
),
migrations.AlterField(
model_name='appconfiguration',
name='show_info',
field=models.BooleanField(default=True, help_text='If disabled, the device can not see how many tickets exist and how many are already scanned. pretixdroid 1.6 or pretixdesk only.', verbose_name='Show information'),
),
]

View File

@@ -12,10 +12,14 @@ class AppConfiguration(models.Model):
items = models.ManyToManyField('pretixbase.Item', blank=True, verbose_name=_('Can scan these products'))
show_info = models.BooleanField(default=True, verbose_name=_('Show information'),
help_text=_('If disabled, the device can not see how many tickets exist and how '
'many are already scanned. pretixdroid 1.6 or newer only.'))
'many are already scanned. pretixdroid 1.6 or pretixdesk only.'))
allow_search = models.BooleanField(default=True, verbose_name=_('Search allowed'),
help_text=_('If disabled, the device can not search for attendees by name. '
'pretixdroid 1.6 or newer only.'))
'pretixdroid 1.6 or pretixdesk only.'))
app = models.CharField(max_length=190, verbose_name=_('Scan software'), default='pretixdroid', choices=(
('pretixdroid', _('pretixdroid for Android smartphones')),
('pretixdesk', _('pretixdesk for desktop computers')),
))
list = models.ForeignKey(
'pretixbase.CheckinList', on_delete=models.CASCADE, verbose_name=_('Check-in list')
)

View File

@@ -19,13 +19,13 @@ def control_nav_import(sender, request=None, **kwargs):
return []
return [
{
'label': _('pretixdroid'),
'label': _('Check-in devices'),
'url': reverse('plugins:pretixdroid:config', kwargs={
'event': request.event.slug,
'organizer': request.event.organizer.slug,
}),
'active': (url.namespace == 'plugins:pretixdroid' and url.url_name == 'config'),
'icon': 'android',
'icon': 'mobile',
}
]

View File

@@ -2,18 +2,19 @@
{% load i18n %}
{% load bootstrap3 %}
{% load staticfiles %}
{% block title %}{% trans "pretixdroid configuration" %}{% endblock %}
{% block title %}{% trans "Check-in device configuration" %}{% endblock %}
{% block content %}
<h1>{% trans "pretixdroid configuration" %}</h1>
<h1>{% trans "Check-in device configuration" %}</h1>
<p>{% blocktrans trimmed %}
pretixdroid is an Android app that you can use to control tickets at the entrance of your event.
pretixdesk is the corresponding app for desktop computers.
{% endblocktrans %}</p>
{% if not configs or "create" in request.GET %}
<h2>{% trans "Create app configuration" %}</h2>
<p>
{% blocktrans trimmed %}
To start scanning tickets with our Android app, first create a configuration code here:
To start scanning tickets with our apps, first create a configuration code here:
{% endblocktrans %}
</p>
<form action="?add" method="post" class="form-horizontal">
@@ -24,6 +25,7 @@
{% bootstrap_field add_form.items layout="horizontal" %}
{% bootstrap_field add_form.show_info layout="horizontal" %}
{% bootstrap_field add_form.allow_search layout="horizontal" %}
{% bootstrap_field add_form.app layout="horizontal" %}
<div class="form-group">
<div class="col-md-offset-3 col-md-9">
<button type="submit" class="btn btn-primary btn-save" name="add" value="1">
@@ -56,7 +58,14 @@
<tbody>
{% for ac in configs %}
<tr>
<td>{{ ac.key|slice:"0:8" }}…</td>
<td>
{% if ac.app == "pretixdroid" %}
<span class="fa fa-fw fa-android"></span>
{% elif ac.app == "pretixdesk" %}
<span class="fa fa-fw fa-desktop"></span>
{% endif %}
{{ ac.key|slice:"0:8" }}…
</td>
<td>
<a href="{% url "control:event.orders.checkinlists.show" organizer=request.event.organizer.slug event=request.event.slug list=ac.list.id %}">{{ ac.list }}</a>
</td>
@@ -74,7 +83,7 @@
<td>{% if ac.allow_search %}{% trans "Yes" %}{% else %}{% trans "No" %}{% endif %}</td>
<td class="text-right">
<a href="{% url "plugins:pretixdroid:config.code" organizer=request.event.organizer.slug event=request.event.slug config=ac.pk %}" class="btn btn-default">
<span class="fa fa-qrcode"></span> {% trans "Show QR code" %}
<span class="fa fa-qrcode"></span> {% trans "Configure device" %}
</a>
<button class="btn btn-danger" name="delete" value="{{ ac.pk }}">
<span class="fa fa-trash"></span>

View File

@@ -2,8 +2,9 @@
{% load i18n %}
{% load bootstrap3 %}
{% load staticfiles %}
{% block title %}{% trans "pretixdroid configuration" %}{% endblock %}
{% block title %}{% trans "Device configuration" %}{% endblock %}
{% block content %}
{% if config.app == "pretixdroid" %}
<h1>
{% trans "pretixdroid configuration" %}
<a href="{% url "plugins:pretixdroid:config" organizer=request.event.organizer.slug event=request.event.slug %}" class="btn btn-default">
@@ -32,5 +33,36 @@
</script>
<h2>{% trans "3. Start scanning tickets" %}</h2>
<script type="text/javascript" src="{% static "pretixplugins/pretixdroid/pretixdroid.js" %}"></script>
{% else %}
<h1>
{% trans "pretixdesk configuration" %}
<a href="{% url "plugins:pretixdroid:config" organizer=request.event.organizer.slug event=request.event.slug %}" class="btn btn-default">
{% trans "Back to overview" %}
</a>
</h1>
<h2>{% trans "1. Download pretixdesk" %}</h2>
<p>
<a href="https://pretix.eu/about/en/desk" class="btn btn-lg btn-primary" target="_blank">
{% trans "Open download page" %}
</a>
</p>
<h2>{% trans "2. Connect device" %}</h2>
<p>
<a href="pretixdesk://setup?{{ query }}" class="btn btn-lg btn-primary">
{% trans "Connect with pretixdesk" %}
</a>
</p>
<p>
{% blocktrans trimmed %}
If this link does not open the pretixdesk application or if you want to set the application up on a
seperate device, copy the following code and paste it into the application:
{% endblocktrans %}
</p>
<p>
<input type="text" class="form-control" value="pretixdesk://setup?{{ query }}" readonly>
</p>
<h2>{% trans "3. Start scanning tickets" %}</h2>
<script type="text/javascript" src="{% static "pretixplugins/pretixdroid/pretixdroid.js" %}"></script>
{% endif %}
{% endblock %}

View File

@@ -1,5 +1,6 @@
import json
import logging
import urllib.parse
import dateutil.parser
from django.contrib import messages
@@ -59,13 +60,16 @@ class ConfigCodeView(EventPermissionRequiredMixin, TemplateView):
'subevent': self.object.subevent.pk
})
ctx['qrdata'] = json.dumps({
data = {
'version': API_VERSION,
'url': url[:-7], # the slice removes the redeem/ part at the end
'key': self.object.key,
'allow_search': self.object.allow_search,
'show_info': self.object.show_info
})
}
ctx['config'] = self.object
ctx['query'] = urllib.parse.urlencode(data, safe=':/')
ctx['qrdata'] = json.dumps(data)
return ctx