Keep view code in the respective apps, implement the template in the profiles app.
This commit is contained in:
parent
50d40eb7df
commit
0b2075425e
|
@ -46,14 +46,16 @@
|
|||
{% if user.orders.exists %}
|
||||
<li><b>Shop</b></li>
|
||||
|
||||
<li {% if view.active_menu == "orders" %}class="active"{% endif %}>
|
||||
<a href="{% url 'shop:order_list' %}">
|
||||
{% url 'shop:order_list' as orders_list_url %}
|
||||
<li {% if "shop/order" in request.path %}class="active"{% endif %}>
|
||||
<a href="{{ orders_list_url }}">
|
||||
Orders
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li {% if view.active_menu == "tickets" %}class="active"{% endif %}>
|
||||
<a href="{% url 'tickets:shopticket_list' %}">
|
||||
{% url 'tickets:shopticket_list' as ticket_list_url %}
|
||||
<li {% if "tickets" in request.path %}class="active"{% endif %}>
|
||||
<a href="{{ ticket_list_url }}">
|
||||
Tickets
|
||||
</a>
|
||||
</li>
|
||||
|
@ -69,7 +71,7 @@
|
|||
{% endif %}
|
||||
|
||||
<li><b>Misc.</b></li>
|
||||
{% url 'profiles:tokenfind_list' as tokenfind_list_url %}
|
||||
{% url 'tokens:tokenfind_list' as tokenfind_list_url %}
|
||||
<li {% if request.path == tokenfind_list_url %}class="active"{% endif %}>
|
||||
<a href="{{ tokenfind_list_url }}">
|
||||
Secret Tokens
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
{% extends 'shop_base.html' %}
|
||||
{% extends 'profile_base.html' %}
|
||||
{% load bootstrap3 %}
|
||||
{% load shop_tags %}
|
||||
|
||||
{% block shop_content %}
|
||||
{% block profile_content %}
|
||||
|
||||
<div class="panel-group">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel panel-heading">
|
||||
|
@ -125,8 +126,8 @@
|
|||
<div class="alert alert-info" style="margin-top: 5px; margin-bottom: -10px;">* Please consider the alternatives before choosing credit card. Credit cards are expensive and difficult for us to handle. Thank you!</div>
|
||||
</div>
|
||||
<div class="panel panel-footer">
|
||||
<i>Bank transfers take up to a week to get registered, but the other
|
||||
payment methods should be more or less instant. Please
|
||||
<i>Bank transfers take up to a week to get registered, but the other
|
||||
payment methods should be more or less instant. Please
|
||||
<a href="{% url 'contact' %}">contact us</a> if your have questions.</i>
|
||||
</div>
|
||||
</div>
|
55
src/profiles/templates/shop/order_list.html
Normal file
55
src/profiles/templates/shop/order_list.html
Normal file
|
@ -0,0 +1,55 @@
|
|||
{% extends 'profile_base.html' %}
|
||||
{% load bootstrap3 %}
|
||||
{% load shop_tags %}
|
||||
{% load bornhack %}
|
||||
|
||||
{% block profile_content %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4>Orders</h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Order ID</th>
|
||||
<th>Items</th>
|
||||
<th>Total amount</th>
|
||||
<th>Open?</th>
|
||||
<th>Paid?</th>
|
||||
<th>Delivered?</th>
|
||||
<th>Invoice</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for order in orders %}
|
||||
{% if order.products.exists %}
|
||||
<tr {% if not order.open and order.paid and order.is_fully_handed_out %}style="color: lightgrey"{% endif %}>
|
||||
<td>{{ order.id }}</td>
|
||||
<td>{{ order.get_number_of_items }}</td>
|
||||
<td>{{ order.total|currency }}</td>
|
||||
<td class="text-center">{{ order.open|truefalseicon }}</td>
|
||||
<td class="text-center">{{ order.paid|truefalseicon }}</td>
|
||||
<td class="text-center">{{ order.handed_out_status }}</td>
|
||||
<td>
|
||||
{% if order.invoice.pdf %}
|
||||
{% url 'shop:download_invoice' pk=order.pk as invoice_download_url %}
|
||||
{% bootstrap_button "PDF" icon="save-file" href=invoice_download_url button_class="btn-primary btn-xs" %}
|
||||
{% else %}
|
||||
N/A
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% url 'shop:order_detail' pk=order.pk as order_detail_url %}
|
||||
{% bootstrap_button "Order details" icon="th-list" href=order_detail_url button_class="btn-primary btn-xs" %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
24
src/profiles/templates/tickets/ticket_detail.html
Normal file
24
src/profiles/templates/tickets/ticket_detail.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
{% extends 'profile_base.html' %}
|
||||
{% load bootstrap3 %}
|
||||
{% load tickets_tags %}
|
||||
|
||||
{% block profile_content %}
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4>Your Tickets</h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
|
||||
<h2>{% if ticket.checked_in %}This ticket has been used{% else %}This ticket is unused{% endif %}</h2>
|
||||
<form method="POST" class="form">
|
||||
{% csrf_token %}
|
||||
{% bootstrap_field form.name %}
|
||||
{% bootstrap_field form.email %}
|
||||
<button class="btn btn-primary form-control" type="submit"><i class="glyphicon glyphicon-check"></i> Save</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
60
src/profiles/templates/tickets/ticket_list.html
Normal file
60
src/profiles/templates/tickets/ticket_list.html
Normal file
|
@ -0,0 +1,60 @@
|
|||
{% extends 'profile_base.html' %}
|
||||
{% load bootstrap3 %}
|
||||
{% load tickets_tags %}
|
||||
|
||||
{% block profile_content %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4>Your Tickets</h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
|
||||
{% if tickets %}
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Ticket owner
|
||||
<th>
|
||||
Product name
|
||||
<th>
|
||||
Price
|
||||
<th>
|
||||
Checked in
|
||||
<th>
|
||||
Actions
|
||||
|
||||
<tbody>
|
||||
{% for ticket in tickets %}
|
||||
<tr>
|
||||
<td>
|
||||
{% if ticket.name %}
|
||||
{{ ticket.name }}
|
||||
{% else %}
|
||||
Anonymous
|
||||
{% endif %}
|
||||
<td>
|
||||
{{ ticket.product.name }}
|
||||
<td>
|
||||
{{ ticket.product.price|currency }}
|
||||
<td>
|
||||
{% if ticket.checked_in %}
|
||||
Yes
|
||||
{% else %}
|
||||
Not yet
|
||||
{% endif %}
|
||||
<td>
|
||||
<a href="{% url 'tickets:shopticket_download' pk=ticket.pk %}" class="btn btn-primary"><i class="fas fa-download" aria-hidden="true"></i> Download PDF</a>
|
||||
{% if not ticket.name %}
|
||||
<a href="{% url 'tickets:shopticket_edit' pk=ticket.pk %}" class="btn btn-primary"><i class="fas fa-edit" aria-hidden="true"></i> Set name</a>
|
||||
{% else %}
|
||||
<a href="{% url 'tickets:shopticket_edit' pk=ticket.pk %}" class="btn btn-primary"><i class="fas fa-edit" aria-hidden="true"></i> Edit name</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
<h3> You don't have any tickets yet. We hope to see you at the next BornHack!</h3>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -1,14 +1,12 @@
|
|||
from django.urls import path
|
||||
|
||||
from .views import ProfileDetail, ProfileUpdate, ProfileTokenFindsView
|
||||
from .views import (
|
||||
ProfileDetail,
|
||||
ProfileUpdate,
|
||||
)
|
||||
|
||||
app_name = 'profiles'
|
||||
urlpatterns = [
|
||||
path('', ProfileDetail.as_view(), name='detail'),
|
||||
path('edit', ProfileUpdate.as_view(), name='update'),
|
||||
path(
|
||||
'tokens',
|
||||
ProfileTokenFindsView.as_view(),
|
||||
name='tokenfind_list'
|
||||
),
|
||||
]
|
||||
|
|
|
@ -3,7 +3,6 @@ from django.views.generic import DetailView, UpdateView
|
|||
from django.urls import reverse_lazy
|
||||
from django.contrib import messages
|
||||
|
||||
from tokens.views import TokenFindListBaseView
|
||||
from . import models
|
||||
|
||||
|
||||
|
@ -32,7 +31,3 @@ class ProfileUpdate(LoginRequiredMixin, UpdateView):
|
|||
form.instance.save()
|
||||
messages.success(self.request, 'Your profile has been updated.')
|
||||
return super().form_valid(form, **kwargs)
|
||||
|
||||
|
||||
class ProfileTokenFindsView(TokenFindListBaseView):
|
||||
template_name = "tokenfind_list.html"
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
{% extends 'shop_base.html' %}
|
||||
{% load bootstrap3 %}
|
||||
{% load shop_tags %}
|
||||
{% load bornhack %}
|
||||
|
||||
{% block shop_content %}
|
||||
<h3>Orders</h3>
|
||||
<table class="table table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Order ID</th>
|
||||
<th>Items</th>
|
||||
<th>Total amount</th>
|
||||
<th>Open?</th>
|
||||
<th>Paid?</th>
|
||||
<th>Delivered?</th>
|
||||
<th>Invoice</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for order in orders %}
|
||||
{% if order.products.exists %}
|
||||
<tr {% if not order.open and order.paid and order.is_fully_handed_out %}style="color: lightgrey"{% endif %}>
|
||||
<td>{{ order.id }}</td>
|
||||
<td>{{ order.get_number_of_items }}</td>
|
||||
<td>{{ order.total|currency }}</td>
|
||||
<td class="text-center">{{ order.open|truefalseicon }}</td>
|
||||
<td class="text-center">{{ order.paid|truefalseicon }}</td>
|
||||
<td class="text-center">{{ order.handed_out_status }}</td>
|
||||
<td>
|
||||
{% if order.invoice.pdf %}
|
||||
{% url 'shop:download_invoice' pk=order.pk as invoice_download_url %}
|
||||
{% bootstrap_button "PDF" icon="save-file" href=invoice_download_url button_class="btn-primary btn-xs" %}
|
||||
{% else %}
|
||||
N/A
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% url 'shop:order_detail' pk=order.pk as order_detail_url %}
|
||||
{% bootstrap_button "Order details" icon="th-list" href=order_detail_url button_class="btn-primary btn-xs" %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
|
@ -16,9 +16,6 @@
|
|||
{% if user.creditnotes.exists %}
|
||||
<li class="pull-right"><a href="{% url 'shop:creditnote_list' %}">Credit Notes</a></li>
|
||||
{% endif %}
|
||||
{% if has_tickets %}
|
||||
<li class="pull-right"><a href="{% url 'tickets:shopticket_list' %}">Tickets</a></li>
|
||||
{% endif %}
|
||||
<li class="pull-right"><a href="{% url 'shop:order_list' %}">Orders</a></li>
|
||||
<li class="pull-right no-before">
|
||||
|
||||
|
|
|
@ -278,7 +278,7 @@ class ProductDetailView(FormView, DetailView):
|
|||
|
||||
class OrderListView(LoginRequiredMixin, ListView):
|
||||
model = Order
|
||||
template_name = "order_list.html"
|
||||
template_name = "shop/order_list.html"
|
||||
context_object_name = 'orders'
|
||||
|
||||
def get_queryset(self):
|
||||
|
@ -288,7 +288,7 @@ class OrderListView(LoginRequiredMixin, ListView):
|
|||
|
||||
class OrderDetailView(LoginRequiredMixin, EnsureUserOwnsOrderMixin, EnsureOrderHasProductsMixin, EnsureOrderIsNotCancelledMixin, DetailView):
|
||||
model = Order
|
||||
template_name = 'order_detail.html'
|
||||
template_name = 'shop/order_detail.html'
|
||||
context_object_name = 'order'
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
{% extends 'tickets_base.html' %}
|
||||
{% load bootstrap3 %}
|
||||
{% load tickets_tags %}
|
||||
|
||||
{% block tickets_content %}
|
||||
|
||||
<div class="well">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-7">
|
||||
<div class="pull-right">
|
||||
<h2>{% if ticket.checked_in %}This ticket has been used{% else %}This ticket is unused{% endif %}</h2>
|
||||
<form method="POST" class="form">
|
||||
{% csrf_token %}
|
||||
{% bootstrap_field form.name %}
|
||||
{% bootstrap_field form.email %}
|
||||
<button class="btn btn-primary form-control" type="submit"><i class="glyphicon glyphicon-check"></i> Save</button>
|
||||
</form>
|
||||
|
||||
<hr />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
|
@ -1,55 +0,0 @@
|
|||
{% extends 'tickets_base.html' %}
|
||||
{% load bootstrap3 %}
|
||||
{% load tickets_tags %}
|
||||
|
||||
{% block tickets_content %}
|
||||
{% if tickets %}
|
||||
<h3>Tickets</h3>
|
||||
|
||||
<table class="table table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Ticket owner
|
||||
<th>
|
||||
Product name
|
||||
<th>
|
||||
Price
|
||||
<th>
|
||||
Checked in
|
||||
<th>
|
||||
Actions
|
||||
|
||||
<tbody>
|
||||
{% for ticket in tickets %}
|
||||
<tr>
|
||||
<td>
|
||||
{% if ticket.name %}
|
||||
{{ ticket.name }}
|
||||
{% else %}
|
||||
Anonymous
|
||||
{% endif %}
|
||||
<td>
|
||||
{{ ticket.product.name }}
|
||||
<td>
|
||||
{{ ticket.product.price|currency }}
|
||||
<td>
|
||||
{% if ticket.checked_in %}
|
||||
Yes
|
||||
{% else %}
|
||||
Not yet
|
||||
{% endif %}
|
||||
<td>
|
||||
<a href="{% url 'tickets:shopticket_download' pk=ticket.pk %}" class="btn btn-primary"><i class="fas fa-download" aria-hidden="true"></i> Download PDF</a>
|
||||
{% if not ticket.name %}
|
||||
<a href="{% url 'tickets:shopticket_edit' pk=ticket.pk %}" class="btn btn-primary"><i class="fas fa-edit" aria-hidden="true"></i> Set name</a>
|
||||
{% else %}
|
||||
<a href="{% url 'tickets:shopticket_edit' pk=ticket.pk %}" class="btn btn-primary"><i class="fas fa-edit" aria-hidden="true"></i> Edit name</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
<h3> You dont have any tickets yet. We hope to see you at the next BornHack!</h3>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
|
@ -1,21 +0,0 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="{% url 'tickets:shopticket_list' %}">Tickets</a></li>
|
||||
<li class="pull-right no-before">
|
||||
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% block tickets_content %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% endblock %}
|
||||
|
|
@ -20,7 +20,7 @@ logger = logging.getLogger("bornhack.%s" % __name__)
|
|||
|
||||
class ShopTicketListView(LoginRequiredMixin, ListView):
|
||||
model = ShopTicket
|
||||
template_name = 'ticket_list.html'
|
||||
template_name = 'tickets/ticket_list.html'
|
||||
context_object_name = 'tickets'
|
||||
|
||||
def get_queryset(self):
|
||||
|
@ -50,7 +50,7 @@ class ShopTicketDownloadView(LoginRequiredMixin, SingleObjectMixin, View):
|
|||
|
||||
class ShopTicketDetailView(LoginRequiredMixin, UpdateView, DetailView):
|
||||
model = ShopTicket
|
||||
template_name = 'ticket_detail.html'
|
||||
template_name = 'tickets/ticket_detail.html'
|
||||
context_object_name = 'ticket'
|
||||
fields = ['name', 'email']
|
||||
|
||||
|
|
|
@ -11,6 +11,6 @@ Secret Token Found! | {{ block.super }}
|
|||
<p class="lead text-center">You found a secret token:</p>
|
||||
<p class="lead text-center"><span class="badge">{{ token.description }}</span></p>
|
||||
<p class="lead text-center">Your visit has been registered! Keep hunting, there might be more tokens out there.</p>
|
||||
<p class="lead text-center"><a href="{% url 'tokens:tokenfind_list' %}">List All Tokens</a></p>
|
||||
<p class="lead text-center"><a href="{% url 'tokens:tokenfind_list' %}">List All Found Tokens</a></p>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
from django.urls import re_path
|
||||
from .views import TokenDetailView
|
||||
from django.urls import re_path, path
|
||||
from .views import TokenDetailView, TokenFindListView
|
||||
|
||||
app_name = 'tokens'
|
||||
|
||||
urlpatterns = [
|
||||
path('', TokenFindListView.as_view(), name='tokenfind_list'),
|
||||
re_path(
|
||||
'(?P<token>[0-9a-zA-Z\.@]+)/$',
|
||||
TokenDetailView.as_view(),
|
||||
|
|
|
@ -19,11 +19,12 @@ class TokenDetailView(LoginRequiredMixin, DetailView):
|
|||
return super().get(request, *args, **kwargs)
|
||||
|
||||
|
||||
class TokenFindListBaseView(LoginRequiredMixin, ListView):
|
||||
class TokenFindListView(LoginRequiredMixin, ListView):
|
||||
"""
|
||||
This class is meant to be extended in other apps like `profiles`.
|
||||
"""
|
||||
model = TokenFind
|
||||
template_name = "tokens/tokenfind_list.html"
|
||||
|
||||
def get_queryset(self):
|
||||
return TokenFind.objects.filter(user=self.request.user)
|
||||
|
|
Loading…
Reference in a new issue