Merge branch 'ludwigsburgalpin'
commit
aa2b12a798
@ -0,0 +1,51 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
from django.contrib import admin
|
||||||
|
from wsgiref.util import FileWrapper
|
||||||
|
from django.http import HttpResponse
|
||||||
|
from django.conf import settings
|
||||||
|
from .models import Group, Termin
|
||||||
|
|
||||||
|
import xlsxwriter
|
||||||
|
|
||||||
|
|
||||||
|
class GroupAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ('name',)
|
||||||
|
|
||||||
|
|
||||||
|
class TerminAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ('title','start_date', 'end_date', 'group')
|
||||||
|
list_filter = ('group',)
|
||||||
|
ordering = ('start_date','end_date')
|
||||||
|
actions = ['make_overview']
|
||||||
|
|
||||||
|
def make_overview(self, request, queryset):
|
||||||
|
filename = 'termine.xlsx'
|
||||||
|
workbook = xlsxwriter.Workbook(media_path(filename))
|
||||||
|
bold = workbook.add_format({'bold': True})
|
||||||
|
worksheet = workbook.add_worksheet()
|
||||||
|
worksheet.write(0, 0, "Titel", bold)
|
||||||
|
worksheet.write(0, 1, "Von", bold)
|
||||||
|
worksheet.write(0, 2, "Bis", bold)
|
||||||
|
worksheet.write(0, 3, "Gruppe", bold)
|
||||||
|
for row, termin in enumerate(queryset):
|
||||||
|
worksheet.write(row+2, 0, termin.title)
|
||||||
|
worksheet.write(row+2, 1, termin.start_date.strftime('%d.%m.%Y'))
|
||||||
|
worksheet.write(row+2, 2, termin.end_date.strftime('%d.%m.%Y'))
|
||||||
|
worksheet.write(row+2, 3, str(termin.group))
|
||||||
|
workbook.close()
|
||||||
|
with open(media_path(filename), 'rb') as xls:
|
||||||
|
response = HttpResponse(FileWrapper(xls))
|
||||||
|
response['Content-Type'] = 'application/xlsx'
|
||||||
|
response['Content-Disposition'] = 'attachment; filename='+filename
|
||||||
|
|
||||||
|
return response
|
||||||
|
make_overview.short_description = "Termine in Excel Liste überführen"
|
||||||
|
|
||||||
|
# Register your models here.
|
||||||
|
admin.site.register(Group, GroupAdmin)
|
||||||
|
admin.site.register(Termin, TerminAdmin)
|
||||||
|
|
||||||
|
|
||||||
|
def media_path(fp):
|
||||||
|
return os.path.join(os.path.join(settings.MEDIA_MEMBERLISTS, "memberlists"), fp)
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class LudwigsburgalpinConfig(AppConfig):
|
||||||
|
name = 'ludwigsburgalpin'
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
class Group(models.Model):
|
||||||
|
name = models.CharField('Name', max_length=50)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = 'Gruppe'
|
||||||
|
verbose_name_plural = 'Gruppen'
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
|
class Termin(models.Model):
|
||||||
|
title = models.CharField('Titel', max_length=100)
|
||||||
|
start_date = models.DateField('Von')
|
||||||
|
end_date = models.DateField('Bis')
|
||||||
|
group = models.ForeignKey('ludwigsburgalpin.Group',
|
||||||
|
verbose_name='Gruppe')
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "{} {}".format(self.title, str(self.group))
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = 'Termin'
|
||||||
|
verbose_name_plural = 'Termine'
|
||||||
@ -0,0 +1,132 @@
|
|||||||
|
body,html{
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 29px;
|
||||||
|
color:#0c1a30;
|
||||||
|
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content {
|
||||||
|
width: 80%;
|
||||||
|
margin: 0 auto;
|
||||||
|
overflow:hidden;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2{
|
||||||
|
font-size: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 a:link, h3 a:visited, h2 a:link, h2 a:visited {
|
||||||
|
color: #58ab27;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-size: 19px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h4 {
|
||||||
|
font-size: 17px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1,h2,h3,h4{
|
||||||
|
color: #58ab27;
|
||||||
|
font-weight: normal;
|
||||||
|
text-shadow: #fff 0px 1px 1px;
|
||||||
|
letter-spacing:0.1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #58ab27;
|
||||||
|
text-decoration: none;
|
||||||
|
outline: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover, a:focus {
|
||||||
|
color: #386d19;
|
||||||
|
text-decoration: none;
|
||||||
|
outline: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.navbar-header {
|
||||||
|
width: 83%;
|
||||||
|
margin: 0 auto;
|
||||||
|
overflow:hidden;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.navbar {
|
||||||
|
float: right;
|
||||||
|
list-style-type: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar > li {
|
||||||
|
float: left;
|
||||||
|
position: relative;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.navbar-brand {
|
||||||
|
line-height: 120px;
|
||||||
|
display: inline-block;
|
||||||
|
height: 120px;
|
||||||
|
opacity: 1;
|
||||||
|
padding: 23px 23px;
|
||||||
|
transition: opacity 0.15s linear;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.navbar-brand:hover {
|
||||||
|
opacity: 0.8;
|
||||||
|
transition: opacity 0.15s linear;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar > li a {
|
||||||
|
display: inline-block;
|
||||||
|
color: #777777;
|
||||||
|
text-align: center;
|
||||||
|
text-transform: uppercase;
|
||||||
|
padding: 16px;
|
||||||
|
line-height: 120px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar > li a:hover {
|
||||||
|
color: #333333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar > li a:before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
height: 5px;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
background-color: #58ab27;
|
||||||
|
visibility: hidden;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.3s linear;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar > li a:hover:before {
|
||||||
|
visibility: visible;
|
||||||
|
opacity: 0.5;
|
||||||
|
transition: opacity 0.3s linear;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar > li.current a:before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
height: 5px;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
background-color: #58ab27;
|
||||||
|
visibility: visible;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 894 B |
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@ -0,0 +1,9 @@
|
|||||||
|
table.termine {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
padding-left: 50px;
|
||||||
|
display: block;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
@ -0,0 +1,47 @@
|
|||||||
|
{% load i18n %}
|
||||||
|
{% load static %}
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>
|
||||||
|
Ludwigsburg Alpin Terminverwaltung
|
||||||
|
</title>
|
||||||
|
<link rel="shortcut icon" href="{% static "ludwigsburgalpin/img/favicon.ico" %}" type="image/x-icon">
|
||||||
|
<link rel="stylesheet" href="{% static "ludwigsburgalpin/base.css" %}">
|
||||||
|
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
|
||||||
|
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
|
||||||
|
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
|
||||||
|
<script>
|
||||||
|
$( function() {
|
||||||
|
$( ".datepicker" ).datepicker({
|
||||||
|
dateFormat: "dd.mm.yy"
|
||||||
|
});
|
||||||
|
} );
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="navbar-header">
|
||||||
|
<a class="navbar-brand" href="http://www.alpenverein-ludwigsburg.de">
|
||||||
|
<img class="navbar-logo" src="{% static "ludwigsburgalpin/img/logo_dav.png" %}">
|
||||||
|
</a>
|
||||||
|
<ul class="navbar">
|
||||||
|
|
||||||
|
<li><a href="/">Jugendgruppen</a></li>
|
||||||
|
<li class="current"><a href="/ludwigsburgalpin">Ludwigsburg Alpin</a></li>
|
||||||
|
<li><a href="/kompass">Kompass</a></li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id=content>
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
{% extends "ludwigsburgalpin/base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<p><b>Termin erfolgreich eingereicht</b></p>
|
||||||
|
|
||||||
|
<p><a href="/ludwigsburgalpin">Hier</a> kannst du einen neuen Termin hinzufügen.</p>
|
||||||
|
{% endblock %}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
{% extends "ludwigsburgalpin/base.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="{% static "ludwigsburgalpin/termine.css" static %}">
|
||||||
|
|
||||||
|
<h1>Ludwigsburg Alpin Termine</h1>
|
||||||
|
|
||||||
|
<p>Hier kannst du einen Termin für deine Gruppe hinzufügen</p>
|
||||||
|
|
||||||
|
{% if error_message %}
|
||||||
|
<p><b>{{ error_message }}</b></p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<form action="" method="post">
|
||||||
|
<table class="termine">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form }}
|
||||||
|
</table>
|
||||||
|
<p><input type="submit" value="Abschicken"/></p>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
from django.conf.urls import url
|
||||||
|
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
app_name = "ludwigsburgalpin"
|
||||||
|
urlpatterns = [
|
||||||
|
url(r'^$', views.index, name='index')
|
||||||
|
# url(r'^subscribe', views.subscribe, name='subscribe'),
|
||||||
|
]
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
from django.shortcuts import render
|
||||||
|
from django import forms
|
||||||
|
from django.http import HttpResponseRedirect
|
||||||
|
from django.contrib.admin import widgets
|
||||||
|
from .models import Group, Termin
|
||||||
|
|
||||||
|
from bootstrap_datepicker.widgets import DatePicker
|
||||||
|
|
||||||
|
datepicker = forms.TextInput(attrs={'class': 'datepicker'})
|
||||||
|
|
||||||
|
|
||||||
|
class TerminForm(forms.Form):
|
||||||
|
title = forms.CharField(label='Titel')
|
||||||
|
start_date = forms.DateField(label='Von',
|
||||||
|
widget=datepicker)
|
||||||
|
end_date = forms.DateField(label='Bis',
|
||||||
|
widget=datepicker)
|
||||||
|
group = forms.ModelChoiceField(label='Gruppe',
|
||||||
|
queryset=Group.objects.all())
|
||||||
|
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
|
def index(request):
|
||||||
|
if request.method == 'POST':
|
||||||
|
form = TerminForm(request.POST)
|
||||||
|
if form.is_valid():
|
||||||
|
termin = Termin(title=form.cleaned_data["title"],
|
||||||
|
start_date=form.cleaned_data["start_date"],
|
||||||
|
end_date=form.cleaned_data["end_date"],
|
||||||
|
group=form.cleaned_data["group"])
|
||||||
|
termin.save()
|
||||||
|
return published(request)
|
||||||
|
else:
|
||||||
|
form = TerminForm()
|
||||||
|
return render(request, 'ludwigsburgalpin/termine.html', {'form': form.as_table()})
|
||||||
|
|
||||||
|
|
||||||
|
def published(request):
|
||||||
|
return render(request, 'ludwigsburgalpin/published.html')
|
||||||
Loading…
Reference in New Issue