Merge branch 'feature/subject-tags' into develop
This commit is contained in:
commit
501502a186
@ -29,7 +29,7 @@
|
|||||||
<section>
|
<section>
|
||||||
<span>
|
<span>
|
||||||
{% for tag in component.tags.all %}
|
{% for tag in component.tags.all %}
|
||||||
<a class="tag__item" href="{% url 'tag-detail' tag.pk %}">{{tag.name}}</a>
|
<a class="tag tag__info" href="{% url 'core:tag-detail' component.subject.school_year.year tag.pk %}">{{tag.name}}</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</span>
|
</span>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@ -1,13 +1,33 @@
|
|||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block head_title %}Delete Tag | {% endblock head_title %}
|
||||||
|
|
||||||
|
{% block breadcrumbs %}
|
||||||
|
<div class="breadcrumbs">
|
||||||
|
<menu>
|
||||||
|
<li><strong><a href="{% url 'core:schoolyear-detail' school_year.year %}">{{ school_year.year }}</a></strong></li>
|
||||||
|
<span>›</span>
|
||||||
|
<li><a href="{% url 'core:student-list' school_year.year %}">Students</a></li>
|
||||||
|
<span>›</span>
|
||||||
|
<li><a href="{% url 'core:stag-list' school_year.year %}">Student Tags</a></li>
|
||||||
|
<span>›</span>
|
||||||
|
<li><a href="{% url 'core:stag-detail' school_year.year tag.pk %}">{{ tag }}</a></li>
|
||||||
|
</menu>
|
||||||
|
</div>
|
||||||
|
{% endblock breadcrumbs %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>Delete Studenttag</h1>
|
<article class="form">
|
||||||
<form method="POST" action="{% url 'core:studenttag-delete' studenttag.pk %}">
|
<header class="form__header">
|
||||||
{% csrf_token %}
|
<h1>Delete Tag</h1>
|
||||||
<p>Are you sure you want to delete "{{ studenttag }}"?</p>
|
</header>
|
||||||
{{ form.as_p }}
|
<form method="POST" action="{% url 'core:stag-delete' school_year.year tag.pk %}">
|
||||||
<p>
|
{% csrf_token %}
|
||||||
<input type="submit" value="Delete"> or <a href="{% url 'core:studenttag-detail' studenttag.pk %}">cancel</a>
|
<p>Are you sure you want to delete "{{ tag }}"?</p>
|
||||||
</p>
|
{{ form.as_p }}
|
||||||
</form>
|
<p>
|
||||||
|
<input type="submit" value="Delete" class="action-delete"> or <a href="{% url 'core:stag-update' school_year.year tag.pk %}">cancel</a>
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
|
</article>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@ -16,7 +16,12 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<article class="form">
|
<article class="form">
|
||||||
<h1>Edit Tag</h1>
|
<header class="form__header">
|
||||||
|
<h1>Edit Tag</h1>
|
||||||
|
<p>
|
||||||
|
<a href="{% url 'core:stag-delete' school_year.year tag.pk %}" class="action-button action-delete">Delete</a>
|
||||||
|
</p>
|
||||||
|
</header>
|
||||||
<form method="POST" action="{% url 'core:stag-update' school_year.year tag.pk %}">
|
<form method="POST" action="{% url 'core:stag-update' school_year.year tag.pk %}">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form.as_p }}
|
{{ form.as_p }}
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
<h1>Subjects</h1>
|
<h1>Subjects</h1>
|
||||||
<a href="{% url 'core:subject-create' school_year.year %}" class="action-button">+ New Subject</a>
|
<a href="{% url 'core:subject-create' school_year.year %}" class="action-button">+ New Subject</a>
|
||||||
</div>
|
</div>
|
||||||
<a href="">Tags →</a>
|
<a href="{% url 'core:tag-list' school_year.year %}">Tags →</a>
|
||||||
</header>
|
</header>
|
||||||
<table class="list__table">
|
<table class="list__table">
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
33
src/core/templates/core/tag_confirm_delete.html
Normal file
33
src/core/templates/core/tag_confirm_delete.html
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block head_title %}Delete Tag | {% endblock head_title %}
|
||||||
|
|
||||||
|
{% block breadcrumbs %}
|
||||||
|
<div class="breadcrumbs">
|
||||||
|
<menu>
|
||||||
|
<li><strong><a href="{% url 'core:schoolyear-detail' school_year.year %}">{{ school_year.year }}</a></strong></li>
|
||||||
|
<span>›</span>
|
||||||
|
<li><a href="{% url 'core:subject-list' school_year.year %}">Subjects</a></li>
|
||||||
|
<span>›</span>
|
||||||
|
<li><a href="{% url 'core:tag-list' school_year.year %}">Tags</a></li>
|
||||||
|
<span>›</span>
|
||||||
|
<li><a href="{% url 'core:tag-detail' school_year.year tag.pk %}">{{ tag }}</a></li>
|
||||||
|
</menu>
|
||||||
|
</div>
|
||||||
|
{% endblock breadcrumbs %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<article class="form">
|
||||||
|
<header class="form__header">
|
||||||
|
<h1>Delete Tag</h1>
|
||||||
|
</header>
|
||||||
|
<form method="POST" action="{% url 'core:tag-delete' school_year.year tag.pk %}">
|
||||||
|
{% csrf_token %}
|
||||||
|
<p>Are you sure you want to delete "{{ tag }}"?</p>
|
||||||
|
{{ form.as_p }}
|
||||||
|
<p>
|
||||||
|
<input type="submit" value="Delete" class="action-delete"> or <a href="{% url 'core:tag-update' school_year.year tag.pk %}">cancel</a>
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
|
</article>
|
||||||
|
{% endblock %}
|
||||||
28
src/core/templates/core/tag_create_form.html
Normal file
28
src/core/templates/core/tag_create_form.html
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block head_title %}New Tag | {% endblock head_title %}
|
||||||
|
|
||||||
|
{% block breadcrumbs %}
|
||||||
|
<div class="breadcrumbs">
|
||||||
|
<menu>
|
||||||
|
<li><strong><a href="{% url 'core:schoolyear-detail' school_year.year %}">{{ school_year.year }}</a></strong></li>
|
||||||
|
<span>›</span>
|
||||||
|
<li><a href="{% url 'core:subject-list' school_year.year %}">Subjects</a></li>
|
||||||
|
<span>›</span>
|
||||||
|
<li><a href="{% url 'core:tag-list' school_year.year %}">Tags</a></li>
|
||||||
|
</menu>
|
||||||
|
</div>
|
||||||
|
{% endblock breadcrumbs %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<article class="form">
|
||||||
|
<h1>+ New Tag</h1>
|
||||||
|
<form method="POST" action="{% url 'core:tag-create' school_year.year %}">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form.as_p }}
|
||||||
|
<p>
|
||||||
|
<input type="submit" value="Create"> or <a href="{% url 'core:tag-list' school_year.year %}">cancel</a>
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
|
</article>
|
||||||
|
{% endblock %}
|
||||||
50
src/core/templates/core/tag_detail.html
Normal file
50
src/core/templates/core/tag_detail.html
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
{% load helpers %}
|
||||||
|
|
||||||
|
{% block head_title %}Tag {{ tag }} | {% endblock head_title %}
|
||||||
|
|
||||||
|
{% block breadcrumbs %}
|
||||||
|
<div class="breadcrumbs">
|
||||||
|
<menu>
|
||||||
|
<li><strong><a href="{% url 'core:schoolyear-detail' school_year.year %}">{{ school_year.year }}</a></strong></li>
|
||||||
|
<span>›</span>
|
||||||
|
<li><a href="{% url 'core:subject-list' school_year.year %}">Subjects</a></li>
|
||||||
|
<span>›</span>
|
||||||
|
<li><a href="{% url 'core:tag-list' school_year.year %}">Tags</a></li>
|
||||||
|
</menu>
|
||||||
|
</div>
|
||||||
|
{% endblock breadcrumbs %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<article class="detail">
|
||||||
|
<header class="detail__header">
|
||||||
|
<div class="detail__title">
|
||||||
|
<h1>{{ tag }}</h1>
|
||||||
|
</div>
|
||||||
|
<a href="{% url 'core:tag-update' school_year.year tag.pk %}" class="action-button">Edit</a>
|
||||||
|
</header>
|
||||||
|
<section>
|
||||||
|
<h3>Subjects with this tag</h3>
|
||||||
|
<table class="list__table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Subject</th>
|
||||||
|
<th>Name</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for component in tag.component_set.all %}
|
||||||
|
<tr class="has-link" onclick="document.location='{% url 'core:component-detail' school_year.year component.subject.pk component.pk %}'">
|
||||||
|
<td>{{ component.subject.name }}</td>
|
||||||
|
<td>{{ component }}</td>
|
||||||
|
</tr>
|
||||||
|
{% empty %}
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">No components tagged yet.</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</section>
|
||||||
|
</article>
|
||||||
|
{% endblock %}
|
||||||
35
src/core/templates/core/tag_form.html
Normal file
35
src/core/templates/core/tag_form.html
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block head_title %}Edit Tag | {% endblock head_title %}
|
||||||
|
|
||||||
|
{% block breadcrumbs %}
|
||||||
|
<div class="breadcrumbs">
|
||||||
|
<menu>
|
||||||
|
<li><strong><a href="{% url 'core:schoolyear-detail' school_year.year %}">{{ school_year.year }}</a></strong></li>
|
||||||
|
<span>›</span>
|
||||||
|
<li><a href="{% url 'core:subject-list' school_year.year %}">Subjects</a></li>
|
||||||
|
<span>›</span>
|
||||||
|
<li><a href="{% url 'core:tag-list' school_year.year %}">Tags</a></li>
|
||||||
|
<span>›</span>
|
||||||
|
<li><a href="{% url 'core:tag-detail' school_year.year tag.pk %}">{{ tag }}</a></li>
|
||||||
|
</menu>
|
||||||
|
</div>
|
||||||
|
{% endblock breadcrumbs %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<article class="form">
|
||||||
|
<header class="form__header">
|
||||||
|
<h1>Edit Tag</h1>
|
||||||
|
<p>
|
||||||
|
<a href="{% url 'core:tag-delete' school_year.year tag.pk %}" class="action-button action-delete">Delete</a>
|
||||||
|
</p>
|
||||||
|
</header>
|
||||||
|
<form method="POST" action="{% url 'core:tag-update' school_year.year tag.pk %}">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form.as_p }}
|
||||||
|
<p>
|
||||||
|
<input type="submit" value="Save changes"> or <a href="{% url 'core:tag-detail' school_year.year tag.pk %}">cancel</a>
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
|
</article>
|
||||||
|
{% endblock %}
|
||||||
32
src/core/templates/core/tag_list.html
Normal file
32
src/core/templates/core/tag_list.html
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
{% load helpers %}
|
||||||
|
|
||||||
|
{% block head_title %}Tags | {% endblock head_title %}
|
||||||
|
|
||||||
|
{% block breadcrumbs %}
|
||||||
|
<div class="breadcrumbs">
|
||||||
|
<menu>
|
||||||
|
<li><strong><a href="{% url 'core:schoolyear-detail' school_year.year %}">{{ school_year.year }}</a></strong></li>
|
||||||
|
<span>›</span>
|
||||||
|
<li><a href="{% url 'core:subject-list' school_year.year %}">Subjects</a></li>
|
||||||
|
</menu>
|
||||||
|
</div>
|
||||||
|
{% endblock breadcrumbs %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<article class="list">
|
||||||
|
<header class="list__header">
|
||||||
|
<div class="list__title">
|
||||||
|
<h1>Tags</h1>
|
||||||
|
<a href="{% url 'core:tag-create' school_year.year %}" class="action-button">+ New Tag</a>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<section>
|
||||||
|
{% for tag in tag_list %}
|
||||||
|
<a href="{% url 'core:tag-detail' school_year.year tag.pk %}" class="tag tag__info">{{ tag }}</a>
|
||||||
|
{% empty %}
|
||||||
|
<p>No tags yet.</p>
|
||||||
|
{% endfor %}
|
||||||
|
</section>
|
||||||
|
</article>
|
||||||
|
{% endblock %}
|
||||||
@ -156,6 +156,37 @@ urlpatterns = [
|
|||||||
])),
|
])),
|
||||||
])),
|
])),
|
||||||
])),
|
])),
|
||||||
|
|
||||||
|
# Tags
|
||||||
|
path('tags/', include([
|
||||||
|
path(
|
||||||
|
'',
|
||||||
|
views.TagListView.as_view(),
|
||||||
|
name='tag-list'
|
||||||
|
),
|
||||||
|
path(
|
||||||
|
'new/',
|
||||||
|
views.TagCreateView.as_view(),
|
||||||
|
name='tag-create'
|
||||||
|
),
|
||||||
|
path('<int:tag_pk>/', include([
|
||||||
|
path(
|
||||||
|
'',
|
||||||
|
views.TagDetailView.as_view(),
|
||||||
|
name='tag-detail'
|
||||||
|
),
|
||||||
|
path(
|
||||||
|
'update/',
|
||||||
|
views.TagUpdateView.as_view(),
|
||||||
|
name='tag-update'
|
||||||
|
),
|
||||||
|
path(
|
||||||
|
'delete/',
|
||||||
|
views.TagDeleteView.as_view(),
|
||||||
|
name='tag-delete'
|
||||||
|
),
|
||||||
|
])),
|
||||||
|
])),
|
||||||
])),
|
])),
|
||||||
|
|
||||||
# SchoolDays
|
# SchoolDays
|
||||||
|
|||||||
@ -409,6 +409,104 @@ class SubjectDeleteView(LoginRequiredMixin, SuccessMessageMixin, DeleteView):
|
|||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
class TagListView(LoginRequiredMixin, ListView):
|
||||||
|
model = Tag
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
context['school_year'] = get_object_or_404(
|
||||||
|
SchoolYear, year=self.kwargs['year']
|
||||||
|
)
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
class TagCreateView(
|
||||||
|
LoginRequiredMixin, SuccessMessageMixin, CreateView
|
||||||
|
):
|
||||||
|
model = Tag
|
||||||
|
success_message = 'Tag created.'
|
||||||
|
template_name_suffix = '_create_form'
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
context['school_year'] = get_object_or_404(
|
||||||
|
SchoolYear, year=self.kwargs['year']
|
||||||
|
)
|
||||||
|
return context
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse('core:tag-list', kwargs={
|
||||||
|
'year': self.kwargs['year']
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
class TagDetailView(LoginRequiredMixin, DetailView):
|
||||||
|
model = Tag
|
||||||
|
pk_url_kwarg = 'tag_pk'
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
queryset = Tag.objects.filter(
|
||||||
|
pk=self.kwargs.get(self.pk_url_kwarg)
|
||||||
|
).prefetch_related(
|
||||||
|
Prefetch(
|
||||||
|
'component_set',
|
||||||
|
queryset=Component.objects.filter(
|
||||||
|
subject__school_year__year=self.kwargs['year']
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return queryset
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
context['school_year'] = get_object_or_404(
|
||||||
|
SchoolYear, year=self.kwargs['year']
|
||||||
|
)
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
class TagUpdateView(
|
||||||
|
LoginRequiredMixin, SuccessMessageMixin, UpdateView
|
||||||
|
):
|
||||||
|
model = Tag
|
||||||
|
pk_url_kwarg = 'tag_pk'
|
||||||
|
success_message = 'Tag saved.'
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
context['school_year'] = get_object_or_404(
|
||||||
|
SchoolYear, year=self.kwargs['year']
|
||||||
|
)
|
||||||
|
return context
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse('core:tag-list', kwargs={
|
||||||
|
'year': self.kwargs['year']
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
class TagDeleteView(
|
||||||
|
LoginRequiredMixin, SuccessMessageMixin, DeleteView
|
||||||
|
):
|
||||||
|
model = Tag
|
||||||
|
pk_url_kwarg = 'tag_pk'
|
||||||
|
success_message = 'Tag deleted.'
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
context['school_year'] = get_object_or_404(
|
||||||
|
SchoolYear, year=self.kwargs['year']
|
||||||
|
)
|
||||||
|
return context
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse('core:tag-list', kwargs={
|
||||||
|
'year': self.kwargs['year']
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
class ComponentListView(LoginRequiredMixin, ListView):
|
class ComponentListView(LoginRequiredMixin, ListView):
|
||||||
model = Component
|
model = Component
|
||||||
|
|
||||||
|
|||||||
@ -144,7 +144,7 @@ STATICFILES_FINDERS = (
|
|||||||
|
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||||
AUTH_USER_MODEL = 'accounts.User'
|
AUTH_USER_MODEL = 'accounts.User'
|
||||||
LOGIN_REDIRECT_URL = reverse_lazy('core:today')
|
LOGIN_REDIRECT_URL = reverse_lazy('core:home')
|
||||||
|
|
||||||
# Decimal settings
|
# Decimal settings
|
||||||
DEFAULT_DECIMAL_PLACES = 2
|
DEFAULT_DECIMAL_PLACES = 2
|
||||||
|
|||||||
@ -219,6 +219,8 @@ input[type=submit],
|
|||||||
border-radius: 0.5rem;
|
border-radius: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button.action-delete,
|
||||||
|
input[type=submit].action-delete,
|
||||||
.action-delete {
|
.action-delete {
|
||||||
background-color: var(--color-danger);
|
background-color: var(--color-danger);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user