Add the remaining "easy" timeline views

This commit is contained in:
Jason McBrayer 2018-04-25 20:06:10 -04:00
parent 498f89b165
commit e6f2734208
1 changed files with 11 additions and 11 deletions

View File

@ -3,11 +3,9 @@ from django.shortcuts import render, redirect
from brutaldon.forms import LoginForm, SettingsForm from brutaldon.forms import LoginForm, SettingsForm
from brutaldon.models import Client, Account from brutaldon.models import Client, Account
from mastodon import Mastodon from mastodon import Mastodon
import datetime
from urllib import parse from urllib import parse
def home(request): def timeline(request, timeline='home', timeline_name='Home'):
now = datetime.datetime.now()
if not (request.session.has_key('instance') and if not (request.session.has_key('instance') and
request.session.has_key('username')): request.session.has_key('username')):
return redirect(login) return redirect(login)
@ -25,7 +23,7 @@ def home(request):
access_token = user.access_token, access_token = user.access_token,
api_base_url = client.api_base_id, api_base_url = client.api_base_id,
ratelimit_method="pace") ratelimit_method="pace")
data = mastodon.timeline() data = mastodon.timeline(timeline)
if request.session.has_key('fullbrutalism'): if request.session.has_key('fullbrutalism'):
fullbrutalism = request.session['fullbrutalism'] fullbrutalism = request.session['fullbrutalism']
@ -33,9 +31,17 @@ def home(request):
fullbrutalism = False fullbrutalism = False
return render(request, 'main/timeline.html', return render(request, 'main/timeline.html',
{'toots': data, 'timeline': 'Home', {'toots': data, 'timeline': timeline_name,
'fullbrutalism': fullbrutalism}) 'fullbrutalism': fullbrutalism})
def home(request):
return timeline(request, 'home', 'Home')
def local(request):
return timeline(request, 'local', 'Local')
def fed(request):
return timeline(request, 'public', 'Federated')
def login(request): def login(request):
if request.method == "GET": if request.method == "GET":
@ -99,12 +105,6 @@ def error(request):
def note(request): def note(request):
return render(request, 'main/timeline.html', {'timeline': 'Notifications'}) return render(request, 'main/timeline.html', {'timeline': 'Notifications'})
def local(request):
return render(request, 'main/timeline.html', {'timeline': 'Local'})
def fed(request):
return render(request, 'main/timeline.html', {'timeline': 'Federated'})
def settings(request): def settings(request):
if request.method == 'POST': if request.method == 'POST':