Create goal with privacy

This commit is contained in:
Mouse Reeve
2021-01-16 11:34:19 -08:00
parent 739b6e19e2
commit 112b9f9332
11 changed files with 161 additions and 16 deletions

View File

@ -71,7 +71,8 @@
{% if goal %}
<section class="section">
<div class="block">
{{ goal }} hi
<h3 class="title is-4">{{ goal.year }} Reading Goal</h3>
{% include 'snippets/goal_progress.html' with goal=goal %}
</div>
</section>
{% endif %}

View File

@ -0,0 +1,43 @@
{% extends 'layout.html' %}
{% block content %}
<section class="block">
<h1 class="title">{{ year }} Reading Progress</h1>
{% if not goal and user == request.user %}
{% now 'Y' as year %}
<article class="card">
<header class="card-header">
<h2 class="card-header-title has-background-primary has-text-white">
<span class="icon icon-book is-size-3 mr-2" aria-hidden="true"></span> {{ year }} reading goal
</h2>
</header>
<section class="card-content content">
<p>Set a goal for how many books you'll finish reading in {{ year }}, and track your progress throughout the year.</p>
{% include 'snippets/goal_form.html' %}
</section>
</article>
{% elif not goal and user != request.user %}
<p>{{ user.display_name }} hasn't set a reading goal for {{ year }}.</p>
{% else %}
{% include 'snippets/goal_progress.html' with goal=goal %}
{% endif %}
</section>
{% if goal.books %}
<section>
<h2 class="title">{% if goal.user == request.user %}Your{% else %}{{ goal.user.display_name }}'s{% endif %} {{ year }} Books</h2>
<div class="columns is-multiline">
{% for book in goal.books %}
<div class="column is-narrow">
<div class="box">
<a href="{{ book.book.local_path }}">
{% include 'snippets/discover/small-book.html' with book=book.book rating=goal.ratings %}
</a>
</div>
</div>
{% endfor %}
</div>
</section>
{% endif %}
{% endblock %}

View File

@ -1,7 +1,9 @@
{% load bookwyrm_tags %}
{% if book %}
{% include 'snippets/book_cover.html' with book=book %}
{% if ratings %}
{% include 'snippets/stars.html' with rating=ratings|dict_key:book.id %}
{% endif %}
<h3 class="title is-6"><a href="/book/{{ book.id }}">{{ book.title }}</a></h3>
{% if book.authors %}

View File

@ -1,4 +1,4 @@
<form method="post" name="goal" action="/goal/{{ year }}">
<form method="post" name="goal" action="{{ request.user.local_path }}/goal/{{ year }}">
{% csrf_token %}
<input type="hidden" name="year" value="{{ year }}">
<input type="hidden" name="user" value="{{ request.user.id }}">
@ -15,16 +15,15 @@
</div>
<div class="column">
<label for="post_status" class="label">
<input type="checkbox" name="post-status" id="post_status" class="checkbox" checked>
Post to feed
<label class="label"><p class="mb-2">Goal privacy:</p>
{% include 'snippets/privacy_select.html' with no_label=True %}
</label>
<div class="field">
{% include 'snippets/privacy_select.html' %}
</div>
</div>
</div>
<label for="post_status" class="label">
<input type="checkbox" name="post-status" id="post_status" class="checkbox" checked>
Post to feed
</label>
<p>
<button type="submit" class="button is-link">Set goal</button>

View File

@ -0,0 +1,10 @@
<p>
{% if goal.progress_percent >= 100 %}
Success!
{% elif goal.progress_percent %}
{{ goal.progress_percent }}% complete!
{% endif %}
{% if goal.user == request.user %}You've{% else %}{{ goal.user.display_name }} has{% endif %} read {% if request.path != goal.local_path %}<a href="{{ goal.local_path }}">{% endif %}{{ goal.book_count }} of {{ goal.goal }} books{% if request.path != goal.local_path %}</a>{% endif %}.
</p>
<progress class="progress is-large" value="{{ goal.book_count }}" max="{{ goal.goal }}">{{ goal.progress_percent }}%</progress>