Fleshing out some templates.

This commit is contained in:
Víðir Valberg Guðmundsson 2018-08-09 14:36:21 +02:00
parent 1c8685d15e
commit 6aa37716d6
5 changed files with 83 additions and 5 deletions

View file

@ -3,10 +3,39 @@
{% block content %} {% block content %}
{{ object.location }} <a class="btn btn-primary" href="{% url 'rideshare:list' camp_slug=camp.slug %}">
<i class="fas fa-chevron-left"></i>
Back
</a>
<hr />
<div class="panel panel-default">
<div class="panel-heading">
<h4>
<strong>{{ object.seats }}</strong>
seats free, going from
<strong>{{ object.location }}</strong>
at
<strong>{{ object.when|date:"jS \o\f F \a\t H:i T" }}</strong>
</h4>
</div>
<div class="panel-body">
<strong>Description:</strong>
<p>
{{ object.description|untrustedcommonmark }}
</p>
</div>
<div class="panel-footer">
<a class="btn btn-success pull-right" href="{% url 'rideshare:contact-confirm' camp_slug=camp.slug pk=object.pk %}">
<i class="fas fa-thumbs-up"></i>
Contact this rideshare
</a>
<span class="clearfix"></span>
</div>
</div>
</div>
{{ object.datetime }}
{{ object.description }}
{% endblock %} {% endblock %}

View file

@ -2,17 +2,49 @@
{% block content %} {% block content %}
<div class="page-header">
<h1>Ridesharing</h1>
</div>
<p>
On this page participants of {{ camp.title }} can communicate about ridesharing to and from the festival.
</p>
<a class="btn btn-success" href="{% url 'rideshare:create' camp_slug=camp.slug %}"> <a class="btn btn-success" href="{% url 'rideshare:create' camp_slug=camp.slug %}">
Create ride Create ride
</a> </a>
<hr /> <table class="table table-condensed table-striped">
<thead>
<th>
When
<th>
Location
<th>
Seats
<th>
<tbody>
{% for ride in ride_list %} {% for ride in ride_list %}
<tr>
<td>
{{ ride.when|date:"c" }}
<td>
{{ ride.location }}
<td>
{{ ride.seats }}
<td>
<a class="btn btn-primary" href="{% url 'rideshare:detail' camp_slug=camp.slug pk=ride.pk %}">
<i class="fas fa-eye"></i> Details
</a>
{{ ride.from_location }} at {{ ride.from_datetime}} {% empty %}
<tr>
<td colspan=4>
No rideshares yet!
{% endfor %} {% endfor %}
</table>
{% endblock %} {% endblock %}

View file

@ -6,6 +6,7 @@ from .views import (
RideDetail, RideDetail,
RideUpdate, RideUpdate,
RideDelete, RideDelete,
RideContactConfirm,
) )
app_name = 'rideshare' app_name = 'rideshare'
@ -38,6 +39,11 @@ urlpatterns = [
RideDelete.as_view(), RideDelete.as_view(),
name='delete' name='delete'
), ),
path(
'confirm/',
RideContactConfirm.as_view(),
name='contact-confirm'
),
]) ])
) )
] ]

View file

@ -5,6 +5,7 @@ from django.views.generic import (
CreateView, CreateView,
UpdateView, UpdateView,
DeleteView, DeleteView,
TemplateView,
) )
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
@ -41,3 +42,11 @@ class RideUpdate(LoginRequiredMixin, CampViewMixin, UpdateView):
class RideDelete(LoginRequiredMixin, CampViewMixin, DeleteView): class RideDelete(LoginRequiredMixin, CampViewMixin, DeleteView):
model = Ride model = Ride
class RideContactConfirm(LoginRequiredMixin, CampViewMixin, DetailView):
model = Ride
template_name = "rideshare/ride_contact_confirm.html"
# class RideContact(View):

View file

@ -5,7 +5,9 @@
<a class="btn {% menubuttonclass 'villages' %}" href="{% url 'village_list' camp_slug=camp.slug %}">Villages</a> <a class="btn {% menubuttonclass 'villages' %}" href="{% url 'village_list' camp_slug=camp.slug %}">Villages</a>
<a class="btn {% menubuttonclass 'sponsors' %}" href="{% url 'sponsors' camp_slug=camp.slug %}">Sponsors</a> <a class="btn {% menubuttonclass 'sponsors' %}" href="{% url 'sponsors' camp_slug=camp.slug %}">Sponsors</a>
<a class="btn {% menubuttonclass 'teams' %}" href="{% url 'teams:list' camp_slug=camp.slug %}">Teams</a> <a class="btn {% menubuttonclass 'teams' %}" href="{% url 'teams:list' camp_slug=camp.slug %}">Teams</a>
{% if request.user.is_authenticated %}
<a class="btn {% menubuttonclass 'rideshare' %}" href="{% url 'rideshare:list' camp_slug=camp.slug %}">Rideshare</a> <a class="btn {% menubuttonclass 'rideshare' %}" href="{% url 'rideshare:list' camp_slug=camp.slug %}">Rideshare</a>
{% endif %}
{% if request.user.is_staff %} {% if request.user.is_staff %}
<a class="btn {% menubuttonclass 'backoffice' %}" href="{% url 'backoffice:index' camp_slug=camp.slug %}">Backoffice</a> <a class="btn {% menubuttonclass 'backoffice' %}" href="{% url 'backoffice:index' camp_slug=camp.slug %}">Backoffice</a>
{% endif %} {% endif %}