New design and renaming for the blog which now named chat

This commit is contained in:
Martin Bley
2022-10-04 17:29:21 +02:00
parent 2f970d6eb4
commit 446a55f3e5
6 changed files with 243 additions and 219 deletions

View File

@@ -2,70 +2,74 @@
{% load i18n static %}
{% load humanize %}
{% block head %}
<title> TipPy Blog</title>
<title> TipPy Blog</title>
{% endblock %}
{% block nav %}
{% include "nav.html" with ls=ls season=season %}
{% include "nav.html" with ls=ls season=season %}
{% endblock %}
{% block body %}
<div id="content-main">
<div class="row">
<div class="col-md-7">
<h2>TipPy Blog</h2>
<p class="text-right">
<a class="btn btn-default" href="/blog/newpost" role="button">Neue Nachricht</a>
</p>
</div>
</div>
{% for post, avatar in posts %}
<div class="row">
<div class="col-md-7">
<div class="panel panel-default">
<div class="panel-heading">
{{post.author.first_name}} schrieb {{post.created|naturaltime}}
<div id="content-main">
<div class="row">
<div class="col-md-7">
<h2>TipPy Blog</h2>
<p class="text-right">
<a class="btn btn-default" href="/blog/newpost" role="button">Neue Nachricht</a>
</p>
</div>
</div>
<div class="panel-body">
{% if avatar %}
<img class="img-circle img-responsive pull-left blog" alt="Profile Pic" src="/media/{{avatar}}" />
{% else %}
<img class="img-circle img-responsive pull-left blog" alt="Profile Pic" src="/media/profiles/dummy.png" />
{% endif %}
{{post.content|safe}}
</div>
</div>
</div>
</div>
{% endfor %}
<div class="row">
<div class="col-md-7">
<nav>
<ul class="pager">
{% if posts.has_previous %}
<li data-toggle="tooltip" title="{% trans 'previous' %}" class="previous">
<a href="/blog/{{ page|add:"-1" }}">
{% else %}
<li data-toggle="tooltip" title="{% trans 'previous' %}" class="previous inactive">
<a href="/blog/{{ page }}">
{% endif %}
<span aria-hidden="true">&larr;</span>
</a>
</li>
Seite {{ posts.number }} von {{ posts.paginator.num_pages }}.
{% if posts.has_next %}
<li data-toggle="tooltip" title="{% trans 'next' %}" class="next">
<a href="/blog/{{ page|add:"1" }}">
{% else %}
<li data-toggle="tooltip" title="{% trans 'next' %}" class="next inactive">
<a href="/blog/{{ page }}">
{% endif %}
<span aria-hidden="true">&rarr;</span>
</a>
</li>
<ul class="media-list">
{% for post, avatar in posts %}
<li class="media">
<a href="#" class="pull-left">
{% if avatar %}
<img class="img-circle img-responsive pull-left blog" alt="Profile Pic"
src="/media/{{ avatar }}"/>
{% else %}
<img class="img-circle img-responsive pull-left blog" alt="Profile Pic"
src="/media/profiles/dummy.png"/>
{% endif %}
</a>
<div class="media-body">
<span class="text-muted pull-right">
<small class="text-muted">{{ post.created|naturaltime }}</small>
</span>
<strong class="text-success">{{ post.author.first_name }}</strong>
<p>{{ post.content|safe }}</p>
</div>
</li>
{% endfor %}
</ul>
</nav>
<div class="row">
<div class="col-md-7">
<nav>
<ul class="pager">
{% if posts.has_previous %}
<li data-toggle="tooltip" title="{% trans 'previous' %}" class="previous">
<a href="/blog/{{ page|add:"-1" }}">
{% else %}
<li data-toggle="tooltip" title="{% trans 'previous' %}" class="previous inactive">
<a href="/blog/{{ page }}">
{% endif %}
<span aria-hidden="true">&larr;</span>
</a>
</li>
Seite {{ posts.number }} von {{ posts.paginator.num_pages }}.
{% if posts.has_next %}
<li data-toggle="tooltip" title="{% trans 'next' %}" class="next">
<a href="/blog/{{ page|add:"1" }}">
{% else %}
<li data-toggle="tooltip" title="{% trans 'next' %}" class="next inactive">
<a href="/blog/{{ page }}">
{% endif %}
<span aria-hidden="true">&rarr;</span>
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

28
templates/chat.xhtml Normal file
View File

@@ -0,0 +1,28 @@
{% load humanize %}
<hr>
<p class="text-left">
<a class="btn btn-default" href="/blog/newpost" role="button">neuer Post</a>
</p>
<ul class="media-list">
{% for post, avatar in posts %}
<li class="media">
<a href="#" class="pull-left">
{% if avatar %}
<img class="img-circle img-responsive pull-left blog" alt="Profile Pic"
src="/media/{{ avatar }}"/>
{% else %}
<img class="img-circle img-responsive pull-left blog" alt="Profile Pic"
src="/media/profiles/dummy.png"/>
{% endif %}
</a>
<div class="media-body">
<span class="text-muted pull-right">
<small class="text-muted">{{ post.created|naturaltime }}</small>
</span>
<strong class="text-success">{{ post.author.first_name }}</strong>
<p>{{ post.content|safe }}</p>
</div>
</li>
{% endfor %}
</ul>

View File

@@ -2,128 +2,119 @@
{% load i18n static %}
{% load humanize %}
{% block head %}
<script type="text/javascript" src="{% static 'javascript/tippy.js'%}"></script>
<script type="text/javascript" src="{% static 'javascript/tippy.js' %}"></script>
{% endblock %}
{% block nav %}
{% include "nav.html" with ls=ls season=season %}
{% include "nav.html" with ls=ls season=season %}
{% endblock %}
{% block body %}
<div id="content-main">
<div class="row">
<div class="col-md-7">
<h2>Neueste Nachrichten</h2>
<p class="text-right">
<a class="btn btn-default" href="/blog/1" role="button">zum Blog</a>
</p>
{% for post, avatar in posts %}
<div class="panel panel-default">
<div class="panel-heading">
{{post.author.first_name}} schrieb {{post.created|naturaltime}}
<div id="content-main">
<div class="row">
<div class="col-md-7">
<h2>Deine Tipps</h2>
<nav>
<ul class="pager">
<li data-toggle="tooltip" title="{% trans 'previous' %}" class="previous"><a
href="/matchday/{{ ls }}/{{ season }}/{{ cur_md|add:"-1"|stringformat:"02i" }}"><span
aria-hidden="true">&larr;</span></a></li>
{{ md_name }}
<li data-toggle="tooltip" title="{% trans 'next' %}" class="next"><a
href="/matchday/{{ ls }}/{{ season }}/{{ cur_md|add:"1"|stringformat:"02i" }}"><span
aria-hidden="true">&rarr;</span></a></li>
</ul>
</nav>
<form role="form" action="" method="post">{% csrf_token %}
<div class="table-responsive">
<table class="table table-hover table-condensed">
<tr>
<th>Anstoß</th>
<th>Heim</th>
<th>Gast</th>
<th>Erg.</th>
<th colspan="2">Tipp</th>
</tr>
{% for match in matches %}
{% if match.started and not match.finished %}
<tr class="danger">{% else %}
<tr>{% endif %}
<td>{{ match.matchDateTime }}</td>
{% if match.iconURLTeam1 != "" %}
<td><img src="{{ match.iconURLTeam1 }}" width="20"/>
{% else %}
<td><img src="{{ STATIC_URL }}{{ match.iconTeam1 }}"/>
{% endif %}
<span class="hidden-xs"> {{ match.nameTeam1 }}</span>
<span class="visible-xs"> {{ match.abbrTeam1 }}</span>
</td>
{% if match.iconURLTeam1 != "" %}
<td><img src="{{ match.iconURLTeam2 }}" width="20"/>
{% else %}
<td><img src="{{ STATIC_URL }}{{ match.iconTeam2 }}"/>
{% endif %}
<span class="hidden-xs"> {{ match.nameTeam2 }}</span>
<span class="visible-xs"> {{ match.abbrTeam2 }}</span>
</td>
<td>{{ match.matchResult }}</td>
<td>{{ match.tippFormTeam1 }}</td>
<td>{{ match.tippFormTeam2 }}</td>
</tr>
{% endfor %}
</table>
</div>
<button type="submit" class="btn btn-default btn-lg btn-block">
<span class="glyphicon glyphicon-saved" aria-hidden="true"></span> Tipps abgeben
</button>
</form>
</div>
</div>
<div class="panel-body">
{% if avatar %}
<img class="img-circle img-responsive pull-left blog" alt="Profile Pic" src="/media/{{avatar}}" />
{% else %}
<img class="img-circle img-responsive pull-left blog" alt="Profile Pic" src="/media/profiles/dummy.png" />
{% endif %}
{{post.content|safe}}
</div>
</div>
{% endfor %}
</div>
</div>
<div class="row">
<div class="col-md-7">
<h2>Deine Tipps</h2>
<nav>
<ul class="pager">
<li data-toggle="tooltip" title="{% trans 'previous' %}" class="previous"><a href="/matchday/{{ ls }}/{{ season }}/{{ cur_md|add:"-1"|stringformat:"02i" }}"><span aria-hidden="true">&larr;</span></a></li>
{{ md_name }}
<li data-toggle="tooltip" title="{% trans 'next' %}" class="next"><a href="/matchday/{{ ls }}/{{ season }}/{{ cur_md|add:"1"|stringformat:"02i" }}"><span aria-hidden="true">&rarr;</span></a></li>
</ul>
</nav>
<form role="form" action="" method="post">{% csrf_token %}
<div class="table-responsive">
<table class="table table-hover table-condensed">
<tr>
<th>Anstoß</th>
<th>Heim</th>
<th>Gast</th>
<th>Erg.</th>
<th colspan="2">Tipp</th>
</tr>
{% for match in matches %}
{% if match.started and not match.finished %}
<tr class="danger">{% else %}<tr>{% endif %}
<td>{{ match.matchDateTime }}</td>
{% if match.iconURLTeam1 != "" %}
<td><img src="{{ match.iconURLTeam1 }}" width="20"/>
{% else %}
<td><img src="{{ STATIC_URL}}{{ match.iconTeam1 }}" />
{% endif %}
<span class="hidden-xs"> {{ match.nameTeam1 }}</span>
<span class="visible-xs"> {{ match.abbrTeam1 }}</span>
</td>
{% if match.iconURLTeam1 != "" %}
<td><img src="{{ match.iconURLTeam2 }}" width="20"/>
{% else %}
<td><img src="{{ STATIC_URL}}{{ match.iconTeam2 }}" />
{% endif %}
<span class="hidden-xs"> {{ match.nameTeam2 }}</span>
<span class="visible-xs"> {{ match.abbrTeam2 }}</span>
</td>
<td>{{ match.matchResult }}</td>
<td>{{ match.tippFormTeam1 }}</td><td>{{ match.tippFormTeam2 }}</td>
</tr>
<div class="row">
{% for mandant, list in mandant_dict.items %}
<div class="col-md-7">
<h4>Mitspieler {{ mandant }}</h4>
<div class="table-responsive">
<table class="table table-hover table-condensed">
<tr>
<th>Tipper</th>
<th>Gesamt</th>
{% for match in matches %}
<th>
{% if match.iconURLTeam1 != "" %}
<img src="{{ match.iconURLTeam1 }}" width="20"/>
{% else %}
<img src="{{ STATIC_URL }}{{ match.iconTeam1 }}"/>
{% endif %}
<br/><br/>
{% if match.iconURLTeam2 != "" %}
<img src="{{ match.iconURLTeam2 }}" width="20"/>
{% else %}
<img src="{{ STATIC_URL }}{{ match.iconTeam2 }}"/>
{% endif %}
</th>
{% endfor %}
</tr>
{% for mate in list %}
<tr>
<td>{{ mate.mate.first_name }}</td>
<td>{{ mate.sum_score }}</td>
{% for tipp in mate.tipps %}
<td>{{ tipp }}</td>
{% endfor %}
{% endfor %}
</tr>
</table>
</div>
</div>
{% endfor %}
</table>
</div>
<button type="submit" class="btn btn-default btn-lg btn-block">
<span class="glyphicon glyphicon-saved" aria-hidden="true"></span> Tipps abgeben
</button>
</form>
<div class="row">
<div class="col-md-7">
<h2>Chat</h2>
{% block chat %}
{% include "chat.xhtml" with posts=posts %}
{% endblock %}
</div>
</div>
</div>
</div>
<div class="row">
{% for mandant, list in mandant_dict.items %}
<div class="col-md-7">
<h4>Mitspieler {{ mandant }}</h4>
<div class="table-responsive">
<table class="table table-hover table-condensed">
<tr>
<th>Tipper</th>
<th>Gesamt</th>
{% for match in matches %}
<th>
{% if match.iconURLTeam1 != "" %}
<img src="{{ match.iconURLTeam1 }}" width="20"/>
{% else %}
<img src="{{ STATIC_URL }}{{ match.iconTeam1 }}" />
{% endif %}
<br /><br />
{% if match.iconURLTeam2 != "" %}
<img src="{{ match.iconURLTeam2 }}" width="20"/>
{% else %}
<img src="{{ STATIC_URL }}{{ match.iconTeam2 }}" />
{% endif %}
</th>
{% endfor %}
</tr>
{% for mate in list %}
<tr>
<td>{{ mate.mate.first_name }}</td>
<td>{{ mate.sum_score }}</td>
{% for tipp in mate.tipps %}
<td>{{ tipp }}</td>
{% endfor %}
{% endfor %}
</tr>
</table>
</div>
</div>
{% endfor %}
</div>
</div>
{% endblock %}

View File

@@ -1,58 +1,58 @@
{% extends "base.html" %}
{% load i18n static %}
{% block head %}
<title> TipPy Blog</title>
<title> TipPy Blog</title>
{% endblock %}
{% block nav %}
{% include "nav.html" with ls=ls season=season %}
{% include "nav.html" with ls=ls season=season %}
{% endblock %}
{% block body %}
<div id="content-main">
{% if form_bp.errors %}
<div>
<p class="errornote">
{% if form_bp.errors.items|length == 1 %}
{% trans "Please correct the error below." %}
{% else %}
{% trans "Please correct the errors below." %}
{% endif %}</p>
</div>
{% endif %}
<div class="row">
<div class="col-md-8">
<form class="form-horizontal" action="" method="post">{% csrf_token %}
<div class="form-group">
{{form_bp.content.errors}}
<label for="id_content" class="col-sm-4 control-label required">{% trans 'Content' %}</label>
<div class="col-sm-5">
<textarea class="form-control" maxlength="256" rows="2"
id="id_content" name="content"></textarea>
{% if cnt_mandants > 1 %}
{{ form_mandants.mandants.label_tag }}
{% for choice in form_mandants.mandants %}
<label for="{{choice.id_for_label}}">
{{ choice.tag }} {{choice.choice_label}}
</label>
{% endfor %}
{% endif %}
</div>
<div id="content-main">
{% if form_bp.errors %}
<div>
<p class="errornote">
{% if form_bp.errors.items|length == 1 %}
{% trans "Please correct the error below." %}
{% else %}
{% trans "Please correct the errors below." %}
{% endif %}</p>
</div>
{% endif %}
<div class="row">
<div class="col-md-8">
<form class="form-horizontal" action="" method="post">{% csrf_token %}
<div class="form-group">
{{ form_bp.content.errors }}
<div class="col-sm-5">
<div class="panel-body">
<textarea class="form-control" placeholder="Schreibe einen Kommentar..." id="id_content"
name="content" maxlength="100" rows="2"></textarea>
{% if cnt_mandants > 1 %}
{{ form_mandants.mandants.label_tag }}
{% for choice in form_mandants.mandants %}
<label for="{{ choice.id_for_label }}">
{{ choice.tag }} {{ choice.choice_label }}
</label>
{% endfor %}
{% endif %}
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">{% trans 'Sent' %}</button>
</div>
</div>
</form>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">{% trans 'Sent' %}</button>
</div>
</div>
</form>
{% if debug %}
<div class="row">
<div class="col-md-8">
<p>{{ debug }}</p>
</div>
</div>
{% endif %}
</div>
</div>
{% if debug %}
<div class="row">
<div class="col-md-8">
<p>{{ debug }}</p>
</div>
</div>
{% endif %}
</div>
{% endblock %}

View File

@@ -25,7 +25,8 @@ urlpatterns = [
re_path(r'^accounts/login/', auth_views.LoginView.as_view()),
re_path(r'^accounts/logout/', auth_views.LogoutView.as_view())
]
# Redirect on logout
LOGOUT_REDIRECT_URL = "home"
if settings.DEBUG is True:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

View File

@@ -446,7 +446,7 @@ def matchday(request, ls, season, matchday, template_name='md.html'):
pm = RelPostMandant.objects.filter(mandant__in=mandants). \
values_list('post', flat=True)
posts = []
for post in Post.objects.filter(id__in=pm, published=True)[:1]:
for post in Post.objects.filter(id__in=pm, published=True)[:5]:
try:
avatar = UserProfile.objects.get(user_id=post.author_id). \
avatar.name