Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 62ec42297d | |||
| 5b033803a8 | |||
| 364166d84b | |||
| de904d4ad4 | |||
| 7c66399c8f | |||
| 6332b49eac | |||
| ae3d3d2c12 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,3 +7,4 @@ old_stuff/
|
||||
static/
|
||||
templates/blogindex.html-media
|
||||
tippy/static/
|
||||
warnings.txt
|
||||
|
||||
@@ -51,8 +51,13 @@
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-md-7">
|
||||
<p>© Martin Bley, 2014-2015 | Dank an <a href="http://openligadb.de">OpenLigaDB</a> für
|
||||
die Bereitstellung der Spielergebnisse.</p>
|
||||
<p>
|
||||
<div class="pull-left">
|
||||
© Martin Bley, 2014-2016 | Dank an
|
||||
<a href="http://openligadb.de">OpenLigaDB</a> für die Bereitstellung der
|
||||
Spielergebnisse.
|
||||
</div>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -24,8 +24,7 @@
|
||||
<div class="col-md-7">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
{{post.author.first_name}} schrieb {{post.created|naturaltime}},
|
||||
<a href="{{post.get_absolute_url}}">{{post.title}}</a>
|
||||
{{post.author.first_name}} schrieb {{post.created|naturaltime}}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{% if avatar %}
|
||||
|
||||
@@ -20,8 +20,7 @@
|
||||
{% for post, avatar in posts %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
{{post.author.first_name}} schrieb {{post.created|naturaltime}},
|
||||
<a href="{{post.get_absolute_url}}">{{post.title}}</a>
|
||||
{{post.author.first_name}} schrieb {{post.created|naturaltime}}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{% if avatar %}
|
||||
|
||||
@@ -23,13 +23,6 @@
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<form class="form-horizontal" action="" method="post">{% csrf_token %}
|
||||
<div class="form-group">
|
||||
{{form.title.errors}}
|
||||
<label for="id_title" class="col-sm-4 control-label required">{% trans 'Title' %}</label>
|
||||
<div class="col-sm-5">
|
||||
<input id="id_title" maxlength="32" name="title" class="form-control" type="text" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{form.content.errors}}
|
||||
<label for="id_content" class="col-sm-4 control-label required">{% trans 'Content' %}</label>
|
||||
|
||||
@@ -23,19 +23,15 @@ from django.contrib import admin
|
||||
|
||||
class PostAdmin(admin.ModelAdmin):
|
||||
# fields display on change list
|
||||
list_display = ['title']
|
||||
list_display = ['content']
|
||||
# fields to filter the change list with
|
||||
list_filter = ['published', 'created']
|
||||
# fields to search in change list
|
||||
search_fields = ['title', 'content']
|
||||
search_fields = ['content']
|
||||
# enable the date drill down on change list
|
||||
date_hierarchy = 'created'
|
||||
# enable the save buttons on top on change form
|
||||
save_on_top = True
|
||||
# prepopulate the slug from the title - big timesaver!
|
||||
prepopulated_fields = {"slug": ("title",)}
|
||||
|
||||
|
||||
|
||||
admin.site.register(Team)
|
||||
admin.site.register(Match)
|
||||
|
||||
@@ -46,7 +46,7 @@ class TippForm(forms.Form):
|
||||
class BlogpostForm(ModelForm):
|
||||
class Meta:
|
||||
model = Post
|
||||
fields = ['title', 'content']
|
||||
fields = ['content']
|
||||
|
||||
class UserForm(forms.ModelForm):
|
||||
class Meta:
|
||||
|
||||
@@ -112,8 +112,6 @@ class RelUserMandant(models.Model):
|
||||
return (str(self.user) + " -> " + str(self.mandant))
|
||||
|
||||
class Post(models.Model):
|
||||
title = models.CharField(max_length=255, null=False, blank=False)
|
||||
slug = models.SlugField(unique=True, max_length=255)
|
||||
content = models.TextField()
|
||||
published = models.BooleanField(default=True)
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
@@ -123,9 +121,6 @@ class Post(models.Model):
|
||||
ordering = ['-created']
|
||||
|
||||
def __unicode__(self):
|
||||
return u'%s' % self.title
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('tipp.views.blogpost', args=[self.slug])
|
||||
return u'%s' % self.created
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,12 @@ from tipp.forms import *
|
||||
from openliga import *
|
||||
from datetime import datetime
|
||||
from PIL import Image as PImage
|
||||
import urllib2, pytz, os
|
||||
import urllib2, pytz, os, sys
|
||||
|
||||
# setting utf-8 as default encoding to avoid errors in file
|
||||
# uploads and form data
|
||||
reload(sys)
|
||||
sys.setdefaultencoding('utf8')
|
||||
|
||||
timezoneLocal = pytz.timezone('Europe/Berlin')
|
||||
|
||||
@@ -68,25 +73,17 @@ def profile(request, pk):
|
||||
|
||||
# If it's a HTTP POST, we're interested in processing form data.
|
||||
if request.method == 'POST':
|
||||
# Attempt to grab information from the raw form information.
|
||||
# Note that we make use of both UserForm and UserProfileForm.
|
||||
user_form = UserForm(data=request.POST, instance=user)
|
||||
profile_form = UserProfileForm(data=request.POST, instance=profile)
|
||||
|
||||
# If the two forms are valid...
|
||||
if user_form.is_valid() and profile_form.is_valid():
|
||||
|
||||
# Save the user's form data to the database.
|
||||
user = user_form.save()
|
||||
|
||||
# Now sort out the UserProfile instance.
|
||||
# Since we need to set the user attribute ourselves, we set commit=False.
|
||||
# This delays saving the model until we're ready to avoid integrity problems.
|
||||
profile = profile_form.save(commit=False)
|
||||
profile.user = user
|
||||
|
||||
# Did the user provide a profile picture?
|
||||
# If so, we need to get it from the input form and put it in the UserProfile model.
|
||||
if 'avatar' in request.FILES:
|
||||
profile.avatar = request.FILES['avatar']
|
||||
# Now we save the UserProfile model instance.
|
||||
@@ -108,8 +105,6 @@ def profile(request, pk):
|
||||
for item in request.POST:
|
||||
debug.append(str(item) + " -> " + str(request.POST[item]))
|
||||
|
||||
|
||||
|
||||
# Invalid form or forms - mistakes or something else?
|
||||
# Print problems to the terminal.
|
||||
# They'll also be shown to the user.
|
||||
@@ -117,6 +112,7 @@ def profile(request, pk):
|
||||
print user_form.errors, profile_form.errors
|
||||
|
||||
return redirect( '/accounts/profile/' + str(user.id) )
|
||||
|
||||
# Not a HTTP POST, so we render our form using two ModelForm instances.
|
||||
# These forms will be blank, ready for user input.
|
||||
else:
|
||||
@@ -335,7 +331,13 @@ def matchday(request, ls, season, matchday, template_name='md.html'):
|
||||
try:
|
||||
matetipp = Tipp.objects.get(tipperID=mate['mate'],matchID=match.matchID)
|
||||
if match_started is True:
|
||||
mate['tipps'].append(str(matetipp.pointsTeam1) + ":" + str(matetipp.pointsTeam2) + "(" + str(matetipp.score) + ")")
|
||||
if matetipp.score is None:
|
||||
score = u'\u231B'
|
||||
else:
|
||||
score = matetipp.score
|
||||
|
||||
mate['tipps'].append(str(matetipp.pointsTeam1) + ":" + str(matetipp.pointsTeam2) + \
|
||||
"(" + str(score) + ")")
|
||||
if match.finished is True:
|
||||
mate['sum_score'] += matetipp.score
|
||||
else:
|
||||
@@ -401,8 +403,11 @@ def charts(request, ls, season, pos='default', template_name='charts.html'):
|
||||
# get user object, then fetch matches for user
|
||||
user = User.objects.get(id=userid)
|
||||
score = Tipp.objects.filter(matchID__in=matches, tipperID=user).aggregate(Sum('score'))
|
||||
|
||||
user_dict[user.first_name] = score['score__sum']
|
||||
|
||||
if score['score__sum'] is None:
|
||||
user_dict[user.first_name] = 0
|
||||
else:
|
||||
user_dict[user.first_name] = score['score__sum']
|
||||
|
||||
mandant_dict[mandant.name] = sorted(user_dict.items(), key=lambda x: x[1], reverse=True)
|
||||
|
||||
@@ -444,17 +449,6 @@ def blogindex(request, page):
|
||||
'page': page
|
||||
})
|
||||
|
||||
@login_required
|
||||
def blogpost(request, slug):
|
||||
# get the Post object
|
||||
post = get_object_or_404(Post, slug=slug)
|
||||
# now return the rendered template
|
||||
return render(request, 'blogpost.html', {
|
||||
'post': post,
|
||||
'ls': get_current_ls(),
|
||||
'season': get_current_season()
|
||||
})
|
||||
|
||||
@login_required
|
||||
def newBlogpost(request):
|
||||
"""
|
||||
@@ -465,12 +459,8 @@ def newBlogpost(request):
|
||||
form = BlogpostForm(request.POST)
|
||||
# check whether it's valid:
|
||||
if form.is_valid():
|
||||
# process the data
|
||||
# fix me
|
||||
# What to to, if subject is empty?
|
||||
data = form.cleaned_data
|
||||
slug = slugify(data['title'])
|
||||
p = Post(author_id=request.user.id, slug=slug, title=data['title'], content=data['content'])
|
||||
p = Post(author_id=request.user.id, content=data['content'])
|
||||
p.save()
|
||||
|
||||
# ...
|
||||
|
||||
@@ -18,7 +18,6 @@ urlpatterns = patterns('',
|
||||
url(r'^accounts/', include('django.contrib.auth.urls')),
|
||||
url(r'^blog/newpost$', 'tipp.views.newBlogpost'),
|
||||
url(r'^blog/(?P<page>\d)$', 'tipp.views.blogindex'),
|
||||
url(r'^blog/(?P<slug>[\w\-]+)', 'tipp.views.blogpost'),
|
||||
|
||||
# Uncomment the admin/doc line below to enable admin documentation:
|
||||
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
||||
|
||||
Reference in New Issue
Block a user