Added a dashboard widget to help starting

This commit is contained in:
Raphael Michel
2016-05-07 14:29:51 +02:00
parent 7ae7da5af1
commit ab37c15bcc
4 changed files with 127 additions and 67 deletions

View File

@@ -0,0 +1,12 @@
<div class="welcome-wizard">
<h3>{{ title }}</h3>
{% if subtitle %}
<div class="attentionline">{{ subtitle }}</div>
{% endif %}
{% if text %}
<p>{{ text }}</p>
{% endif %}
{% if button_text %}
<p><a href="{{ button_url }}" class="btn btn-default btn-lg">{{ button_text }}</a></p>
{% endif %}
</div>

View File

@@ -4,6 +4,7 @@ from django.core.urlresolvers import reverse
from django.db.models import Sum from django.db.models import Sum
from django.dispatch import receiver from django.dispatch import receiver
from django.shortcuts import render from django.shortcuts import render
from django.template.loader import get_template
from django.utils import formats from django.utils import formats
from django.utils.formats import date_format from django.utils.formats import date_format
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
@@ -110,6 +111,40 @@ def shop_state_widget(sender, **kwargs):
}] }]
@receiver(signal=event_dashboard_widgets)
def welcome_wizard_widget(sender, **kwargs):
template = get_template('pretixcontrol/event/dashboard_widget_welcome.html')
ctx = {
'title': _('Welcome to pretix!')
}
kwargs = {'event': sender.slug, 'organizer': sender.organizer.slug}
if not sender.items.exists():
ctx.update({
'subtitle': _('Get started by creating a product'),
'text': _('The first thing you need for selling tickets to your conference is one or more "products" your '
'participants can choose from. A product can be a ticket or anything else that you want to sell, '
'e.g. additional merchandise in form of t-shirts.'),
'button_text': _('Create a first product'),
'button_url': reverse('control:event.items.add', kwargs=kwargs)
})
elif not sender.quotas.exists():
ctx.update({
'subtitle': _('Create quotas that apply to your products'),
'text': _('Your tickets will only be available for sale if you create a matching quota, i.e. if you tell '
'pretix how many tickets it should sell for your event.'),
'button_text': _('Create a first quota'),
'button_url': reverse('control:event.items.quotas.add', kwargs=kwargs)
})
else:
return []
return [{
'width': 12,
'priority': 2000,
'content': template.render(ctx)
}]
def event_index(request, organizer, event): def event_index(request, organizer, event):
widgets = [] widgets = []
for r, result in event_dashboard_widgets.send(sender=request.event): for r, result in event_dashboard_widgets.send(sender=request.event):

View File

@@ -0,0 +1,79 @@
.dashboard-panels .panel-heading .fa {
opacity: 0.5;
}
.dashboard > div {
padding: 5px;
}
.dashboard .widget {
min-height: 160px;
background: #F8F8F8;
display: block;
position: relative;
}
.dashboard .widget:hover,.dashboard .widget:focus {
background: #EEEEEE;
text-decoration: none;
}
.dashboard .numwidget {
.num {
display: block;
padding: 28px 0 10px;
text-align: center;
font-size: 40px;
}
.text {
display: block;
text-align: center;
font-size: 20px;
}
}
.dashboard .shopstate {
text-align: center;
padding: 36px 0;
span.live, span.off {
display: block;
font-size: 20px;
padding: 10px 0;
}
span.live {
color: $brand-success;
}
span.off {
color: $brand-danger;
}
}
.dashboard .event {
text-align: center;
padding: 30px;
font-size: 20px;
span.from, span.to {
display: block;
font-size: 25px;
}
}
.dashboard .newevent {
text-align: center;
padding: 30px;
font-size: 20px;
span.fa {
display: block;
font-size: 60px;
padding-bottom: 15px;
}
}
.dashboard .welcome-wizard {
padding: 30px;
h3 {
margin: 0 0 10px 0;
}
.attentionline {
font-size: 18px;
margin: 0 0 10px 0;
}
p:last-child {
margin-bottom: 0;
}
}

View File

@@ -7,6 +7,7 @@ $fa-font-path: static("fontawesome/fonts");
@import "_forms.scss"; @import "_forms.scss";
@import "_flags.scss"; @import "_flags.scss";
@import "_orders.scss"; @import "_orders.scss";
@import "_dashboard.scss";
footer { footer {
text-align: center; text-align: center;
@@ -81,79 +82,12 @@ h1 .btn-sm {
-ms-transform: rotateX(180deg); /* IE 9 */ -ms-transform: rotateX(180deg); /* IE 9 */
-webkit-transform: rotateX(180deg); /* Safari and Chrome */ -webkit-transform: rotateX(180deg); /* Safari and Chrome */
} }
.dashboard-panels .panel-heading .fa {
opacity: 0.5;
}
@media (max-width: $screen-sm-max) { @media (max-width: $screen-sm-max) {
.navbar-nav { .navbar-nav {
margin-left: 0; margin-left: 0;
} }
} }
.dashboard > div {
padding: 5px;
}
.dashboard .widget {
min-height: 160px;
background: #F8F8F8;
display: block;
position: relative;
}
.dashboard .widget:hover,.dashboard .widget:focus {
background: #EEEEEE;
text-decoration: none;
}
.dashboard .numwidget {
.num {
display: block;
padding: 28px 0 10px;
text-align: center;
font-size: 40px;
}
.text {
display: block;
text-align: center;
font-size: 20px;
}
}
.dashboard .shopstate {
text-align: center;
padding: 36px 0;
span.live, span.off {
display: block;
font-size: 20px;
padding: 10px 0;
}
span.live {
color: $brand-success;
}
span.off {
color: $brand-danger;
}
}
.dashboard .event {
text-align: center;
padding: 30px;
font-size: 20px;
span.from, span.to {
display: block;
font-size: 25px;
}
}
.dashboard .newevent {
text-align: center;
padding: 30px;
font-size: 20px;
span.fa {
display: block;
font-size: 60px;
padding-bottom: 15px;
}
}
.helper-display-inline { .helper-display-inline {
display: inline !important; display: inline !important;