Adding team guides (markdown text)
This commit is contained in:
parent
4dab2c1a4f
commit
9b9138f08c
|
@ -304,4 +304,16 @@ body.bar-menu {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.team-guide-markdown
|
||||||
|
{
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
padding: 10px 20px;
|
||||||
|
}
|
||||||
|
.team-guide-markdown h1,
|
||||||
|
.team-guide-markdown h2,
|
||||||
|
.team-guide-markdown h3,
|
||||||
|
.team-guide-markdown h4,
|
||||||
|
{
|
||||||
|
font-size: 80%;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
|
@ -13,6 +13,10 @@ class TeamTaskAdmin(admin.ModelAdmin):
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class TeamMemberInline(admin.TabularInline):
|
||||||
|
model = TeamMember
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Team)
|
@admin.register(Team)
|
||||||
class TeamAdmin(admin.ModelAdmin):
|
class TeamAdmin(admin.ModelAdmin):
|
||||||
def get_responsible(self, obj):
|
def get_responsible(self, obj):
|
||||||
|
@ -30,6 +34,7 @@ class TeamAdmin(admin.ModelAdmin):
|
||||||
'camp',
|
'camp',
|
||||||
'needs_members',
|
'needs_members',
|
||||||
]
|
]
|
||||||
|
inlines = [TeamMemberInline]
|
||||||
|
|
||||||
|
|
||||||
@admin.register(TeamMember)
|
@admin.register(TeamMember)
|
||||||
|
|
20
src/teams/migrations/0019_team_guide.py
Normal file
20
src/teams/migrations/0019_team_guide.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.5 on 2017-11-25 21:32
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('teams', '0018_auto_20171122_2204'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='team',
|
||||||
|
name='guide',
|
||||||
|
field=models.TextField(blank=True, default='\n# Preparations\n\n...\n\n# Camp setup\n\n...\n\n# During camp\n\n...\n\n# Takedown\n\n...\n\n# Notes for next year\n\n 1. Remember to take notes\n 1. ...\n', help_text='HowTo guide for this year (and next year)', verbose_name='team guide (Markdown)'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -11,6 +11,30 @@ import logging
|
||||||
logger = logging.getLogger("bornhack.%s" % __name__)
|
logger = logging.getLogger("bornhack.%s" % __name__)
|
||||||
|
|
||||||
|
|
||||||
|
TEAM_GUIDE_TEMPLATE="""
|
||||||
|
# Preparations
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
# Camp setup
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
# During camp
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
# Takedown
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
# Notes for next year
|
||||||
|
|
||||||
|
1. Remember to take notes
|
||||||
|
1. ...
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class TeamArea(CampRelatedModel):
|
class TeamArea(CampRelatedModel):
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['name']
|
ordering = ['name']
|
||||||
|
@ -50,6 +74,13 @@ class Team(CampRelatedModel):
|
||||||
)
|
)
|
||||||
mailing_list = models.EmailField(blank=True)
|
mailing_list = models.EmailField(blank=True)
|
||||||
|
|
||||||
|
guide = models.TextField(
|
||||||
|
blank=True,
|
||||||
|
help_text="HowTo guide for this year (and next year)",
|
||||||
|
verbose_name="team guide (Markdown)",
|
||||||
|
default=TEAM_GUIDE_TEMPLATE,
|
||||||
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '{} ({})'.format(self.name, self.camp)
|
return '{} ({})'.format(self.name, self.camp)
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,15 @@ Team: {{ team.name }} | {{ block.super }}
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading"><h4>{{ team.name }} Team</h4></div>
|
<div class="panel-heading"><h4>{{ team.name }} Team</h4></div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
|
||||||
|
|
||||||
{{ team.description|unsafecommonmark }}
|
{{ team.description|unsafecommonmark }}
|
||||||
|
|
||||||
|
{% if request.user|is_team_member:team %}
|
||||||
|
<a href="{% url 'teams:guide' camp_slug=camp.slug team_slug=team.slug %}" class="btn btn-primary">Team guide</a>
|
||||||
|
{% endif %}
|
||||||
{% if request.user in team.responsible.all %}
|
{% if request.user in team.responsible.all %}
|
||||||
<a href="{% url 'teams:manage' camp_slug=camp.slug team_slug=team.slug %}" class="btn btn-primary">Manage Team</a>
|
<a href="{% url 'teams:manage' camp_slug=camp.slug team_slug=team.slug %}" class="btn btn-default">Manage team</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
25
src/teams/templates/team_guide.html
Normal file
25
src/teams/templates/team_guide.html
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
{% load commonmark %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
Guide for: {{ team.name }} | {{ block.super }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1 class="page-header">Guide / Howto for {{ team.name }}</h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<a href="{% url 'teams:guide_print' camp_slug=camp.slug team_slug=team.slug %}" class="btn btn-default" target="_blank">Print</a>
|
||||||
|
{% if request.user in team.responsible.all %}
|
||||||
|
<a href="{% url 'teams:manage' camp_slug=camp.slug team_slug=team.slug %}" class="btn btn-warning">Edit</a>
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="team-guide-markdown">
|
||||||
|
{{ team.guide|unsafecommonmark }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
10
src/teams/templates/team_guide_print.html
Normal file
10
src/teams/templates/team_guide_print.html
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<html>{% load commonmark %}
|
||||||
|
<head>
|
||||||
|
<title>{{ team.name }}</title>
|
||||||
|
</head>
|
||||||
|
<body onload="window.print()">
|
||||||
|
|
||||||
|
{{ team.guide|unsafecommonmark }}
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -1,4 +1,5 @@
|
||||||
from django import template
|
from django import template
|
||||||
|
from teams.models import TeamMember
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
|
@ -6,3 +7,7 @@ register = template.Library()
|
||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def membershipstatus(user, team):
|
def membershipstatus(user, team):
|
||||||
return team.memberstatus(user)
|
return team.memberstatus(user)
|
||||||
|
|
||||||
|
@register.filter
|
||||||
|
def is_team_member(user, team):
|
||||||
|
return TeamMember.objects.filter(team=team, user=user, approved=True).exists()
|
||||||
|
|
|
@ -43,6 +43,16 @@ urlpatterns = [
|
||||||
TeamManageView.as_view(),
|
TeamManageView.as_view(),
|
||||||
name='manage'
|
name='manage'
|
||||||
),
|
),
|
||||||
|
url(
|
||||||
|
r'^guide/$',
|
||||||
|
TeamGuideView.as_view(),
|
||||||
|
name='guide'
|
||||||
|
),
|
||||||
|
url(
|
||||||
|
r'^guide/print/$',
|
||||||
|
TeamGuidePrintView.as_view(),
|
||||||
|
name='guide_print'
|
||||||
|
),
|
||||||
url(
|
url(
|
||||||
r'^tasks/', include([
|
r'^tasks/', include([
|
||||||
url(
|
url(
|
||||||
|
|
|
@ -14,6 +14,8 @@ from django.core.urlresolvers import reverse_lazy
|
||||||
from profiles.models import Profile
|
from profiles.models import Profile
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from django.utils.decorators import method_decorator
|
||||||
logger = logging.getLogger("bornhack.%s" % __name__)
|
logger = logging.getLogger("bornhack.%s" % __name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,13 +47,36 @@ class TeamDetailView(CampViewMixin, DetailView):
|
||||||
class TeamManageView(CampViewMixin, EnsureTeamResponsibleMixin, UpdateView):
|
class TeamManageView(CampViewMixin, EnsureTeamResponsibleMixin, UpdateView):
|
||||||
model = Team
|
model = Team
|
||||||
template_name = "team_manage.html"
|
template_name = "team_manage.html"
|
||||||
fields = ['description', 'needs_members']
|
fields = ['description', 'guide', 'needs_members']
|
||||||
slug_url_kwarg = 'team_slug'
|
slug_url_kwarg = 'team_slug'
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse_lazy('teams:detail', kwargs={'camp_slug': self.camp.slug, 'slug': self.get_object().slug})
|
return reverse_lazy('teams:detail', kwargs={'camp_slug': self.camp.slug, 'slug': self.get_object().slug})
|
||||||
|
|
||||||
|
|
||||||
|
class TeamGuideView(CampViewMixin, DetailView):
|
||||||
|
template_name = "team_guide.html"
|
||||||
|
context_object_name = 'team'
|
||||||
|
model = Team
|
||||||
|
slug_url_kwarg = 'team_slug'
|
||||||
|
|
||||||
|
@method_decorator(login_required)
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
return CampViewMixin.dispatch(self, request, *args, **kwargs)
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
qs = CampViewMixin.get_queryset(self)
|
||||||
|
qs.filter(
|
||||||
|
teammember__approved=True,
|
||||||
|
teammember__user=self.request.user,
|
||||||
|
)
|
||||||
|
return qs
|
||||||
|
|
||||||
|
|
||||||
|
class TeamGuidePrintView(TeamGuideView):
|
||||||
|
template_name = "team_guide_print.html"
|
||||||
|
|
||||||
|
|
||||||
class TeamJoinView(LoginRequiredMixin, CampViewMixin, UpdateView):
|
class TeamJoinView(LoginRequiredMixin, CampViewMixin, UpdateView):
|
||||||
template_name = "team_join.html"
|
template_name = "team_join.html"
|
||||||
model = Team
|
model = Team
|
||||||
|
|
Loading…
Reference in a new issue