mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Generalize pretixdroid settings UI
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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'),
|
||||
),
|
||||
]
|
||||
@@ -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')
|
||||
)
|
||||
|
||||
@@ -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',
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -2,35 +2,67 @@
|
||||
{% load i18n %}
|
||||
{% load bootstrap3 %}
|
||||
{% load staticfiles %}
|
||||
{% block title %}{% trans "pretixdroid configuration" %}{% endblock %}
|
||||
{% block title %}{% trans "Device configuration" %}{% endblock %}
|
||||
{% block content %}
|
||||
<h1>
|
||||
{% trans "pretixdroid 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 app" %}</h2>
|
||||
<p>
|
||||
<a href="http://play.google.com/store/apps/details?id=eu.pretix.pretixdroid">
|
||||
<img src="{% static "pretixplugins/pretixdroid/play_store_en.png" %}" alt="
|
||||
{% trans "Download the app from the Google Play Store" %}" height="70">
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<small>
|
||||
{% blocktrans trimmed %}
|
||||
Android, Google Play and the Google Play logo are trademarks of Google Inc.
|
||||
{% endblocktrans %}
|
||||
</small>
|
||||
</p>
|
||||
<h2>{% trans "2. Scan code" %}</h2>
|
||||
<div id="qrcodeCanvas"></div>
|
||||
<script type="text/json" id="qrdata">
|
||||
{{ qrdata|safe }}
|
||||
{% 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">
|
||||
{% trans "Back to overview" %}
|
||||
</a>
|
||||
</h1>
|
||||
<h2>{% trans "1. Download app" %}</h2>
|
||||
<p>
|
||||
<a href="http://play.google.com/store/apps/details?id=eu.pretix.pretixdroid">
|
||||
<img src="{% static "pretixplugins/pretixdroid/play_store_en.png" %}" alt="
|
||||
{% trans "Download the app from the Google Play Store" %}" height="70">
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<small>
|
||||
{% blocktrans trimmed %}
|
||||
Android, Google Play and the Google Play logo are trademarks of Google Inc.
|
||||
{% endblocktrans %}
|
||||
</small>
|
||||
</p>
|
||||
<h2>{% trans "2. Scan code" %}</h2>
|
||||
<div id="qrcodeCanvas"></div>
|
||||
<script type="text/json" id="qrdata">
|
||||
{{ qrdata|safe }}
|
||||
|
||||
</script>
|
||||
<h2>{% trans "3. Start scanning tickets" %}</h2>
|
||||
<script type="text/javascript" src="{% static "pretixplugins/pretixdroid/pretixdroid.js" %}"></script>
|
||||
</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 %}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user