forked from mirrors/bookwyrm
Handle goal pages for unset years
This commit is contained in:
parent
97b643ac72
commit
535ff5e6d8
2 changed files with 7 additions and 2 deletions
|
@ -17,9 +17,9 @@
|
|||
|
||||
{% block panel %}
|
||||
<section class="block">
|
||||
{% if user == request.user %}
|
||||
{% now 'Y' as current_year %}
|
||||
{% if user == request.user and year == current_year %}
|
||||
<div class="block">
|
||||
{% now 'Y' as year %}
|
||||
<section class="card {% if goal %}is-hidden{% endif %}" id="show-edit-goal">
|
||||
<header class="card-header">
|
||||
<h2 class="card-header-title has-background-primary has-text-white" tabindex="0" id="edit-form-header">
|
||||
|
|
|
@ -4,6 +4,7 @@ from django.http import HttpResponseNotFound
|
|||
from django.shortcuts import redirect
|
||||
from django.template.loader import get_template
|
||||
from django.template.response import TemplateResponse
|
||||
from django.utils import timezone
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views import View
|
||||
from django.views.decorators.http import require_POST
|
||||
|
@ -26,6 +27,10 @@ class Goal(View):
|
|||
if not goal and user != request.user:
|
||||
return HttpResponseNotFound()
|
||||
|
||||
current_year = timezone.now().year
|
||||
if not goal and year != timezone.now().year:
|
||||
return redirect('user-goal', username, current_year)
|
||||
|
||||
if goal and not goal.visible_to_user(request.user):
|
||||
return HttpResponseNotFound()
|
||||
|
||||
|
|
Loading…
Reference in a new issue