Adds markup for set goal status on feed page

This commit is contained in:
Mouse Reeve 2021-01-16 08:19:54 -08:00
parent b648012af5
commit 3a7271309e
5 changed files with 80 additions and 6 deletions

View file

@ -48,7 +48,7 @@
<div class="card-header">
<p class="card-header-title">
<span>{% include 'snippets/book_titleby.html' with book=book %}</span>
</>
</p>
<div class="card-header-icon is-hidden-tablet">
{% include 'snippets/toggle/toggle_button.html' with label="close" controls_text="no-book" class="delete" %}
</div>
@ -67,6 +67,14 @@
<input class="toggle-control" type="radio" name="recent-books" id="no-book">
</div>
{% endif %}
{% if goal %}
<section class="section">
<div class="block">
{{ goal }} hi
</div>
</section>
{% endif %}
</div>
<div class="column is-two-thirds" id="feed">
@ -85,6 +93,33 @@
</ul>
</div>
{# announcements and system messages #}
{% if not goal and tab == 'home' %}
<section class="block" aria-title="Announcements">
{% now 'Y' as year %}
<article class="card">
<header class="card-header">
<h3 class="card-header-title has-background-primary has-text-white">
{{ year }} reading goal
</h3>
</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>
<footer class="card-footer has-background-white-bis">
<div class="card-footer-item is-flex-direction-column">
<button class="button is-danger is-light is-block">Dismiss message</button>
<p class="help">You can set or change your reading goal any time from your <a href="{{ request.user.local_path }}">profile page</a></p>
</div>
</footer>
</article>
</section>
{% endif %}
<hr>
{# activity feed #}
{% if not activities %}
<p>There aren't any activities right now! Try following a user to get started</p>
{% endif %}

View file

@ -29,8 +29,8 @@
<footer class="modal-card-foot">
<div class="columns">
<div class="column field">
<label for="post-status">
<input type="checkbox" name="post-status" class="checkbox" checked>
<label for="post_status-{{ uuid }}">
<input type="checkbox" name="post-status" class="checkbox" id="post_status-{{ uuid }}" checked>
Post to feed
</label>
{% include 'snippets/privacy_select.html' %}

View file

@ -0,0 +1,32 @@
<form method="post" name="goal" action="/goal/{{ year }}">
{% csrf_token %}
<input type="hidden" name="year" value="{{ year }}">
<input type="hidden" name="user" value="{{ request.user.id }}">
<div class="columns">
<div class="column">
<label class="label" for="id_goal">Reading goal:</label>
<div class="field has-addons">
<div class="control">
<input type="number" class="input" name="goal" id="id_goal" value="12">
</div>
<p class="button is-static">books</p>
</div>
</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>
<div class="field">
{% include 'snippets/privacy_select.html' %}
</div>
</div>
</div>
<p>
<button type="submit" class="button is-link">Set goal</button>
</p>
</form>

View file

@ -20,8 +20,8 @@
<footer class="modal-card-foot">
<div class="columns">
<div class="column field">
<label for="post-status">
<input type="checkbox" name="post-status" class="checkbox" checked>
<label for="post_status-{{ uuid }}">
<input type="checkbox" name="post-status" class="checkbox" id="post_status-{{ uuid }}" checked>
Post to feed
</label>
{% include 'snippets/privacy_select.html' %}

View file

@ -3,6 +3,7 @@ from django.contrib.auth.decorators import login_required
from django.core.paginator import Paginator
from django.db.models import Avg, Max
from django.template.response import TemplateResponse
from django.utils import timezone
from django.utils.decorators import method_decorator
from django.views import View
@ -86,12 +87,18 @@ class Feed(View):
activities = get_activity_feed(
request.user, ['public', 'followers'])
paginated = Paginator(activities, PAGE_LENGTH)
goal = models.AnnualGoal.objects.filter(
user=request.user, year=timezone.now().year
).first()
data = {
'title': 'Updates Feed',
'user': request.user,
'suggested_books': suggested_books,
'activities': paginated.page(page),
'tab': tab,
'goal': goal,
'goal_form': forms.GoalForm(),
}
return TemplateResponse(request, 'feed.html', data)