Adds back home/local/federated tabs

I don't think this is how I want the UI to work in the long run,
but for now it's better than not having it.
Fixes #210
This commit is contained in:
Mouse Reeve 2020-10-05 13:34:43 -07:00
parent 9c83d68a80
commit 8d9474275e
3 changed files with 23 additions and 1 deletions

View file

@ -33,6 +33,20 @@
</div>
<div class="column is-two-thirds" id="feed">
<div class="tabs">
<ul>
<li class="{% if tab == 'home' %}is-active{% endif %}">
<a href="/#feed">Home</a>
</li>
<li class="{% if tab == 'local' %}is-active{% endif %}">
<a href="/local#feed">Local</a>
</li>
<li class="{% if tab == 'federated' %}is-active{% endif %}">
<a href="/federated#feed">Federated</a>
</li>
</ul>
</div>
{% if not activities %}
<p>There aren't any activities right now! Try following a user to get started</p>
{% endif %}

View file

@ -45,6 +45,7 @@ urlpatterns = [
re_path(r'^invite/(?P<code>[A-Za-z0-9]+)/?$', views.invite_page),
path('', views.home),
re_path(r'^(?P<tab>home|local|federated)/?$', views.home_tab),
re_path(r'^notifications/?', views.notifications_page),
re_path(r'import/?$', views.import_page),
re_path(r'import_status/(\d+)/?$', views.import_status),

View file

@ -44,6 +44,12 @@ def not_found_page(request, _):
@login_required
def home(request):
''' this is the same as the feed on the home tab '''
return home_tab(request, 'home')
@login_required
def home_tab(request, tab):
''' user's homepage with activity feed '''
# TODO: why on earth would this be where the pagination is set
page_size = 15
@ -81,7 +87,7 @@ def home(request):
if len(suggested_books) >= count:
break
activities = get_activity_feed(request.user, 'home')
activities = get_activity_feed(request.user, tab)
activity_count = activities.count()
activities = activities[(page - 1) * page_size:page * page_size]
@ -94,6 +100,7 @@ def home(request):
'activities': activities,
'review_form': forms.ReviewForm(),
'quotation_form': forms.QuotationForm(),
'tab': tab,
'comment_form': forms.CommentForm(),
'next': next_page if activity_count > (page_size * page) else None,
'prev': prev_page if page > 1 else None,