Fix up old_login to work with new preferences system
This commit is contained in:
parent
fea88a541e
commit
26cb87b73e
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 2.1 on 2018-08-26 22:53
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('brutaldon', '0011_auto_20180825_1017'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='account',
|
||||||
|
name='username',
|
||||||
|
field=models.EmailField(max_length=254, unique=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -17,9 +17,9 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label">{{ form.username.label }}</label>
|
<label class="label">{{ form.email.label }}</label>
|
||||||
<div class="control has-icons-left">
|
<div class="control has-icons-left">
|
||||||
{% render_field form.username class+="input" %}
|
{% render_field form.email class+="input" %}
|
||||||
<span class="icon is-small is-left">
|
<span class="icon is-small is-left">
|
||||||
<i class="fa fa-user"></i>
|
<i class="fa fa-user"></i>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -24,28 +24,28 @@ class Singleton(type):
|
||||||
class MastodonPool(dict, metaclass=Singleton):
|
class MastodonPool(dict, metaclass=Singleton):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_mastodon(request):
|
def get_usercontext(request):
|
||||||
pool = MastodonPool()
|
if is_logged_in(request):
|
||||||
try:
|
pool = MastodonPool()
|
||||||
client = Client.objects.get(api_base_id=request.session['instance'])
|
try:
|
||||||
user = Account.objects.get(username=request.session['username'])
|
client = Client.objects.get(api_base_id=request.session['instance'])
|
||||||
except (Client.DoesNotExist, Client.MultipleObjectsReturned,
|
user = Account.objects.get(username=request.session['username'])
|
||||||
Account.DoesNotExist, Account.MultipleObjectsReturned):
|
except (Client.DoesNotExist, Client.MultipleObjectsReturned,
|
||||||
raise NotLoggedInException()
|
Account.DoesNotExist, Account.MultipleObjectsReturned):
|
||||||
if user.access_token in pool.keys():
|
raise NotLoggedInException()
|
||||||
mastodon = pool[user.access_token]
|
if user.access_token in pool.keys():
|
||||||
|
mastodon = pool[user.access_token]
|
||||||
|
else:
|
||||||
|
mastodon = Mastodon(
|
||||||
|
client_id = client.client_id,
|
||||||
|
client_secret = client.client_secret,
|
||||||
|
access_token = user.access_token,
|
||||||
|
api_base_url = client.api_base_id,
|
||||||
|
ratelimit_method="throw")
|
||||||
|
pool[user.access_token] = mastodon
|
||||||
|
return user, mastodon
|
||||||
else:
|
else:
|
||||||
mastodon = Mastodon(
|
return None, None
|
||||||
client_id = client.client_id,
|
|
||||||
client_secret = client.client_secret,
|
|
||||||
access_token = user.access_token,
|
|
||||||
api_base_url = client.api_base_id,
|
|
||||||
ratelimit_method="throw")
|
|
||||||
pool[user.access_token] = mastodon
|
|
||||||
return mastodon
|
|
||||||
|
|
||||||
def fullbrutalism_p(request):
|
|
||||||
return request.session.get('fullbrutalism', False)
|
|
||||||
|
|
||||||
def is_logged_in(request):
|
def is_logged_in(request):
|
||||||
return request.session.has_key('user')
|
return request.session.has_key('user')
|
||||||
|
@ -88,7 +88,7 @@ def br_login_required(function=None, home_url=None, redirect_field_name=None):
|
||||||
return _dec(function)
|
return _dec(function)
|
||||||
|
|
||||||
def timeline(request, timeline='home', timeline_name='Home', max_id=None, since_id=None):
|
def timeline(request, timeline='home', timeline_name='Home', max_id=None, since_id=None):
|
||||||
mastodon = get_mastodon(request)
|
account, mastodon = get_usercontext(request)
|
||||||
data = mastodon.timeline(timeline, limit=100, max_id=max_id, since_id=since_id)
|
data = mastodon.timeline(timeline, limit=100, max_id=max_id, since_id=since_id)
|
||||||
form = PostForm(initial={'visibility': request.session['user'].source.privacy})
|
form = PostForm(initial={'visibility': request.session['user'].source.privacy})
|
||||||
try:
|
try:
|
||||||
|
@ -111,7 +111,7 @@ def timeline(request, timeline='home', timeline_name='Home', max_id=None, since_
|
||||||
{'toots': data, 'form': form, 'timeline': timeline,
|
{'toots': data, 'form': form, 'timeline': timeline,
|
||||||
'timeline_name': timeline_name,
|
'timeline_name': timeline_name,
|
||||||
'own_acct': request.session['user'],
|
'own_acct': request.session['user'],
|
||||||
'fullbrutalism': fullbrutalism_p(request),
|
'preferences': account.preferences,
|
||||||
'prev': prev, 'next': next})
|
'prev': prev, 'next': next})
|
||||||
|
|
||||||
@br_login_required
|
@br_login_required
|
||||||
|
@ -129,14 +129,14 @@ def fed(request, next=None, prev=None):
|
||||||
@br_login_required
|
@br_login_required
|
||||||
def tag(request, tag):
|
def tag(request, tag):
|
||||||
try:
|
try:
|
||||||
mastodon = get_mastodon(request)
|
account, mastodon = get_usercontext(request)
|
||||||
except NotLoggedInException:
|
except NotLoggedInException:
|
||||||
return redirect(login)
|
return redirect(login)
|
||||||
data = mastodon.timeline_hashtag(tag)
|
data = mastodon.timeline_hashtag(tag)
|
||||||
return render(request, 'main/timeline.html',
|
return render(request, 'main/timeline.html',
|
||||||
{'toots': data, 'timeline_name': '#'+tag,
|
{'toots': data, 'timeline_name': '#'+tag,
|
||||||
'own_acct': request.session['user'],
|
'own_acct': request.session['user'],
|
||||||
'fullbrutalism': fullbrutalism_p(request)})
|
'preferences': account.preferences})
|
||||||
|
|
||||||
@never_cache
|
@never_cache
|
||||||
def login(request):
|
def login(request):
|
||||||
|
@ -251,14 +251,15 @@ def old_login(request):
|
||||||
try:
|
try:
|
||||||
account = Account.objects.get(email=email, client_id=client.id)
|
account = Account.objects.get(email=email, client_id=client.id)
|
||||||
except (Account.DoesNotExist, Account.MultipleObjectsReturned):
|
except (Account.DoesNotExist, Account.MultipleObjectsReturned):
|
||||||
preferences = Preferences(theme = Theme.objects.get(1))
|
preferences = Preference(theme = Theme.objects.get(id=1))
|
||||||
|
preferences.save()
|
||||||
account = Account(
|
account = Account(
|
||||||
email = email,
|
email = email,
|
||||||
access_token = "",
|
access_token = "",
|
||||||
client = client,
|
client = client,
|
||||||
preferences = preferences)
|
preferences = preferences)
|
||||||
try:
|
try:
|
||||||
access_token = mastodon.log_in(username,
|
access_token = mastodon.log_in(email,
|
||||||
password)
|
password)
|
||||||
account.access_token = access_token
|
account.access_token = access_token
|
||||||
user = mastodon.account_verify_credentials()
|
user = mastodon.account_verify_credentials()
|
||||||
|
@ -285,7 +286,7 @@ def error(request):
|
||||||
@br_login_required
|
@br_login_required
|
||||||
def note(request, next=None, prev=None):
|
def note(request, next=None, prev=None):
|
||||||
try:
|
try:
|
||||||
mastodon = get_mastodon(request)
|
account, mastodon = get_usercontext(request)
|
||||||
except NotLoggedInException:
|
except NotLoggedInException:
|
||||||
return redirect(about)
|
return redirect(about)
|
||||||
notes = mastodon.notifications(limit=100, max_id=next, since_id=prev)
|
notes = mastodon.notifications(limit=100, max_id=next, since_id=prev)
|
||||||
|
@ -303,23 +304,23 @@ def note(request, next=None, prev=None):
|
||||||
{'notes': notes,'timeline': 'Notifications',
|
{'notes': notes,'timeline': 'Notifications',
|
||||||
'timeline_name': 'Notifications',
|
'timeline_name': 'Notifications',
|
||||||
'own_acct': request.session['user'],
|
'own_acct': request.session['user'],
|
||||||
'fullbrutalism': fullbrutalism_p(request),
|
'preferences': account.preferences,
|
||||||
'prev': prev, 'next': next})
|
'prev': prev, 'next': next})
|
||||||
|
|
||||||
@br_login_required
|
@br_login_required
|
||||||
def thread(request, id):
|
def thread(request, id):
|
||||||
mastodon = get_mastodon(request)
|
account, mastodon = get_usercontext(request)
|
||||||
context = mastodon.status_context(id)
|
context = mastodon.status_context(id)
|
||||||
toot = mastodon.status(id)
|
toot = mastodon.status(id)
|
||||||
return render(request, 'main/thread.html',
|
return render(request, 'main/thread.html',
|
||||||
{'context': context, 'toot': toot,
|
{'context': context, 'toot': toot,
|
||||||
'own_acct': request.session['user'],
|
'own_acct': request.session['user'],
|
||||||
'fullbrutalism': fullbrutalism_p(request)})
|
'preferences': account.preferences})
|
||||||
|
|
||||||
@br_login_required
|
@br_login_required
|
||||||
def user(request, username, prev=None, next=None):
|
def user(request, username, prev=None, next=None):
|
||||||
try:
|
try:
|
||||||
mastodon = get_mastodon(request)
|
account, mastodon = get_usercontext(request)
|
||||||
except NotLoggedInException:
|
except NotLoggedInException:
|
||||||
return redirect(about)
|
return redirect(about)
|
||||||
try:
|
try:
|
||||||
|
@ -343,7 +344,7 @@ def user(request, username, prev=None, next=None):
|
||||||
{'toots': data, 'user': user_dict,
|
{'toots': data, 'user': user_dict,
|
||||||
'relationship': relationship,
|
'relationship': relationship,
|
||||||
'own_acct': request.session['user'],
|
'own_acct': request.session['user'],
|
||||||
'fullbrutalism': fullbrutalism_p(request),
|
'preferences': account.preferences,
|
||||||
'prev': prev, 'next': next})
|
'prev': prev, 'next': next})
|
||||||
|
|
||||||
|
|
||||||
|
@ -358,6 +359,7 @@ def settings(request):
|
||||||
account.preferences.filter_replies = form.cleaned_data['filter_replies']
|
account.preferences.filter_replies = form.cleaned_data['filter_replies']
|
||||||
account.preferences.filter_boosts = form.cleaned_data['filter_boosts']
|
account.preferences.filter_boosts = form.cleaned_data['filter_boosts']
|
||||||
account.preferences.timezone = form.cleaned_data['timezone']
|
account.preferences.timezone = form.cleaned_data['timezone']
|
||||||
|
request.session['timezone'] = account.preferences.timezone
|
||||||
account.preferences.save()
|
account.preferences.save()
|
||||||
account.save()
|
account.save()
|
||||||
return redirect(home)
|
return redirect(home)
|
||||||
|
@ -365,6 +367,7 @@ def settings(request):
|
||||||
return render(request, 'setup/settings.html',
|
return render(request, 'setup/settings.html',
|
||||||
{'form' : form, 'account': account})
|
{'form' : form, 'account': account})
|
||||||
else:
|
else:
|
||||||
|
request.session['timezone'] = account.preferences.timezone
|
||||||
form = PreferencesForm(account.preferences)
|
form = PreferencesForm(account.preferences)
|
||||||
return render(request, 'setup/settings.html',
|
return render(request, 'setup/settings.html',
|
||||||
{ 'form': form,
|
{ 'form': form,
|
||||||
|
@ -384,11 +387,11 @@ def toot(request, mention=None):
|
||||||
return render(request, 'main/post.html',
|
return render(request, 'main/post.html',
|
||||||
{'form': form,
|
{'form': form,
|
||||||
'own_acct': request.session['user'],
|
'own_acct': request.session['user'],
|
||||||
'fullbrutalism': fullbrutalism_p(request)})
|
'preferences': account.preferences})
|
||||||
elif request.method == 'POST':
|
elif request.method == 'POST':
|
||||||
form = PostForm(request.POST, request.FILES)
|
form = PostForm(request.POST, request.FILES)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
mastodon = get_mastodon(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
|
||||||
# create media objects
|
# create media objects
|
||||||
media_objects = []
|
media_objects = []
|
||||||
|
@ -411,14 +414,14 @@ def toot(request, mention=None):
|
||||||
return render(request, 'main/post.html',
|
return render(request, 'main/post.html',
|
||||||
{'form': form,
|
{'form': form,
|
||||||
'own_acct': request.session['user'],
|
'own_acct': request.session['user'],
|
||||||
'fullbrutalism': fullbrutalism_p(request)})
|
'preferences': account.preferences})
|
||||||
else:
|
else:
|
||||||
return redirect(toot)
|
return redirect(toot)
|
||||||
|
|
||||||
@br_login_required
|
@br_login_required
|
||||||
def redraft(request, id):
|
def redraft(request, id):
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
mastodon = get_mastodon(request)
|
account, mastodon = get_usercontext(request)
|
||||||
toot = mastodon.status(id)
|
toot = mastodon.status(id)
|
||||||
toot_content = BeautifulSoup(toot.content).get_text("\n")
|
toot_content = BeautifulSoup(toot.content).get_text("\n")
|
||||||
form = PostForm({'status': toot_content,
|
form = PostForm({'status': toot_content,
|
||||||
|
@ -432,10 +435,10 @@ def redraft(request, id):
|
||||||
return render(request, 'main/redraft.html',
|
return render(request, 'main/redraft.html',
|
||||||
{'toot': toot, 'form': form, 'redraft':True,
|
{'toot': toot, 'form': form, 'redraft':True,
|
||||||
'own_acct': request.session['user'],
|
'own_acct': request.session['user'],
|
||||||
'fullbrutalism': fullbrutalism_p(request)})
|
'preferences': account.preferences})
|
||||||
elif request.method == 'POST':
|
elif request.method == 'POST':
|
||||||
form = PostForm(request.POST, request.FILES)
|
form = PostForm(request.POST, request.FILES)
|
||||||
mastodon = get_mastodon(request)
|
account, mastodon = get_usercontext(request)
|
||||||
toot = mastodon.status(id)
|
toot = mastodon.status(id)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
media_objects = []
|
media_objects = []
|
||||||
|
@ -460,7 +463,7 @@ def redraft(request, id):
|
||||||
return render(request, 'main/redraft.html',
|
return render(request, 'main/redraft.html',
|
||||||
{'toot': toot, 'form': form, 'redraft': True,
|
{'toot': toot, 'form': form, 'redraft': True,
|
||||||
'own_acct': request.session['user'],
|
'own_acct': request.session['user'],
|
||||||
'fullbrutalism': fullbrutalism_p(request)})
|
'preferences': account.preferences})
|
||||||
else:
|
else:
|
||||||
return redirect(redraft, id)
|
return redirect(redraft, id)
|
||||||
|
|
||||||
|
@ -479,7 +482,7 @@ def safe_get_attachment(toot, index):
|
||||||
@br_login_required
|
@br_login_required
|
||||||
def reply(request, id):
|
def reply(request, id):
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
mastodon = get_mastodon(request)
|
account, mastodon = get_usercontext(request)
|
||||||
toot = mastodon.status(id)
|
toot = mastodon.status(id)
|
||||||
context = mastodon.status_context(id)
|
context = mastodon.status_context(id)
|
||||||
if toot.account.acct != request.session['user'].acct:
|
if toot.account.acct != request.session['user'].acct:
|
||||||
|
@ -496,10 +499,10 @@ def reply(request, id):
|
||||||
return render(request, 'main/reply.html',
|
return render(request, 'main/reply.html',
|
||||||
{'context': context, 'toot': toot, 'form': form, 'reply':True,
|
{'context': context, 'toot': toot, 'form': form, 'reply':True,
|
||||||
'own_acct': request.session['user'],
|
'own_acct': request.session['user'],
|
||||||
'fullbrutalism': fullbrutalism_p(request)})
|
'preferences': account.preferences})
|
||||||
elif request.method == 'POST':
|
elif request.method == 'POST':
|
||||||
form = PostForm(request.POST, request.FILES)
|
form = PostForm(request.POST, request.FILES)
|
||||||
mastodon = get_mastodon(request)
|
account, mastodon = get_usercontext(request)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
# create media objects
|
# create media objects
|
||||||
media_objects = []
|
media_objects = []
|
||||||
|
@ -523,14 +526,14 @@ def reply(request, id):
|
||||||
return render(request, 'main/reply.html',
|
return render(request, 'main/reply.html',
|
||||||
{'context': context, 'toot': toot, 'form': form, 'reply': True,
|
{'context': context, 'toot': toot, 'form': form, 'reply': True,
|
||||||
'own_acct': request.session['user'],
|
'own_acct': request.session['user'],
|
||||||
'fullbrutalism': fullbrutalism_p(request)})
|
'preferences': account.preferences})
|
||||||
else:
|
else:
|
||||||
return redirect(reply, id)
|
return redirect(reply, id)
|
||||||
|
|
||||||
@never_cache
|
@never_cache
|
||||||
@br_login_required
|
@br_login_required
|
||||||
def fav(request, id):
|
def fav(request, id):
|
||||||
mastodon = get_mastodon(request)
|
account, mastodon = get_usercontext(request)
|
||||||
toot = mastodon.status(id)
|
toot = mastodon.status(id)
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
if not request.POST.get('cancel', None):
|
if not request.POST.get('cancel', None):
|
||||||
|
@ -544,12 +547,12 @@ def fav(request, id):
|
||||||
{"toot": toot,
|
{"toot": toot,
|
||||||
'own_acct': request.session['user'],
|
'own_acct': request.session['user'],
|
||||||
"confirm_page": True,
|
"confirm_page": True,
|
||||||
'fullbrutalism': fullbrutalism_p(request)})
|
'preferences': account.preferences})
|
||||||
|
|
||||||
@never_cache
|
@never_cache
|
||||||
@br_login_required
|
@br_login_required
|
||||||
def boost(request, id):
|
def boost(request, id):
|
||||||
mastodon = get_mastodon(request)
|
account, mastodon = get_usercontext(request)
|
||||||
toot = mastodon.status(id)
|
toot = mastodon.status(id)
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
if not request.POST.get('cancel', None):
|
if not request.POST.get('cancel', None):
|
||||||
|
@ -563,12 +566,12 @@ def boost(request, id):
|
||||||
{"toot": toot,
|
{"toot": toot,
|
||||||
'own_acct': request.session['user'],
|
'own_acct': request.session['user'],
|
||||||
'confirm_page': True,
|
'confirm_page': True,
|
||||||
"fullbrutalism": fullbrutalism_p(request)})
|
"preferences": account.preferences})
|
||||||
|
|
||||||
@never_cache
|
@never_cache
|
||||||
@br_login_required
|
@br_login_required
|
||||||
def delete(request, id):
|
def delete(request, id):
|
||||||
mastodon = get_mastodon(request)
|
account, mastodon = get_usercontext(request)
|
||||||
toot = mastodon.status(id)
|
toot = mastodon.status(id)
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
if toot.account.acct != request.session['user'].acct:
|
if toot.account.acct != request.session['user'].acct:
|
||||||
|
@ -581,12 +584,12 @@ def delete(request, id):
|
||||||
{"toot": toot,
|
{"toot": toot,
|
||||||
'own_acct': request.session['user'],
|
'own_acct': request.session['user'],
|
||||||
'confirm_page': True,
|
'confirm_page': True,
|
||||||
"fullbrutalism": fullbrutalism_p(request)})
|
"preferences": account.preferences})
|
||||||
|
|
||||||
@never_cache
|
@never_cache
|
||||||
@br_login_required
|
@br_login_required
|
||||||
def follow(request, id):
|
def follow(request, id):
|
||||||
mastodon = get_mastodon(request)
|
account, mastodon = get_usercontext(request)
|
||||||
try:
|
try:
|
||||||
user_dict = mastodon.account(id)
|
user_dict = mastodon.account(id)
|
||||||
relationship = mastodon.account_relationships(user_dict.id)[0]
|
relationship = mastodon.account_relationships(user_dict.id)[0]
|
||||||
|
@ -604,12 +607,12 @@ def follow(request, id):
|
||||||
{"user": user_dict, "relationship": relationship,
|
{"user": user_dict, "relationship": relationship,
|
||||||
"confirm_page": True,
|
"confirm_page": True,
|
||||||
'own_acct': request.session['user'],
|
'own_acct': request.session['user'],
|
||||||
'fullbrutalism': fullbrutalism_p(request)})
|
'preferences': account.preferences})
|
||||||
|
|
||||||
@never_cache
|
@never_cache
|
||||||
@br_login_required
|
@br_login_required
|
||||||
def block(request, id):
|
def block(request, id):
|
||||||
mastodon = get_mastodon(request)
|
account, mastodon = get_usercontext(request)
|
||||||
try:
|
try:
|
||||||
user_dict = mastodon.account(id)
|
user_dict = mastodon.account(id)
|
||||||
relationship = mastodon.account_relationships(user_dict.id)[0]
|
relationship = mastodon.account_relationships(user_dict.id)[0]
|
||||||
|
@ -627,12 +630,12 @@ def block(request, id):
|
||||||
{"user": user_dict, "relationship": relationship,
|
{"user": user_dict, "relationship": relationship,
|
||||||
"confirm_page": True,
|
"confirm_page": True,
|
||||||
'own_acct': request.session['user'],
|
'own_acct': request.session['user'],
|
||||||
'fullbrutalism': fullbrutalism_p(request)})
|
'preferences': account.preferences})
|
||||||
|
|
||||||
@never_cache
|
@never_cache
|
||||||
@br_login_required
|
@br_login_required
|
||||||
def mute(request, id):
|
def mute(request, id):
|
||||||
mastodon = get_mastodon(request)
|
account, mastodon = get_usercontext(request)
|
||||||
try:
|
try:
|
||||||
user_dict = mastodon.account(id)
|
user_dict = mastodon.account(id)
|
||||||
relationship = mastodon.account_relationships(user_dict.id)[0]
|
relationship = mastodon.account_relationships(user_dict.id)[0]
|
||||||
|
@ -650,12 +653,12 @@ def mute(request, id):
|
||||||
{"user": user_dict, "relationship": relationship,
|
{"user": user_dict, "relationship": relationship,
|
||||||
"confirm_page": True,
|
"confirm_page": True,
|
||||||
'own_acct': request.session['user'],
|
'own_acct': request.session['user'],
|
||||||
'fullbrutalism': fullbrutalism_p(request)})
|
'preferences': account.preferences})
|
||||||
|
|
||||||
@br_login_required
|
@br_login_required
|
||||||
def search(request):
|
def search(request):
|
||||||
return render(request, 'main/search.html',
|
return render(request, 'main/search.html',
|
||||||
{"fullbrutalism": fullbrutalism_p(request),
|
{"preferences": account.preferences,
|
||||||
'own_acct': request.session['user'],
|
'own_acct': request.session['user'],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -667,31 +670,37 @@ def search_results(request):
|
||||||
query = request.POST.get('q', '')
|
query = request.POST.get('q', '')
|
||||||
else:
|
else:
|
||||||
query = ''
|
query = ''
|
||||||
mastodon = get_mastodon(request)
|
account, mastodon = get_usercontext(request)
|
||||||
results = mastodon.search(query)
|
results = mastodon.search(query)
|
||||||
return render(request, 'main/search_results.html',
|
return render(request, 'main/search_results.html',
|
||||||
{"results": results,
|
{"results": results,
|
||||||
'own_acct': request.session['user'],
|
'own_acct': request.session['user'],
|
||||||
"fullbrutalism": fullbrutalism_p(request)})
|
"preferences": account.preferences})
|
||||||
|
|
||||||
def about(request):
|
def about(request):
|
||||||
version = django_settings.BRUTALDON_VERSION
|
version = django_settings.BRUTALDON_VERSION
|
||||||
|
account, mastodon = get_usercontext(request)
|
||||||
|
if account:
|
||||||
|
preferences = account.preferences
|
||||||
|
else:
|
||||||
|
preferences = None
|
||||||
return render(request, 'about.html',
|
return render(request, 'about.html',
|
||||||
{"fullbrutalism": fullbrutalism_p(request),
|
{"preferences": preferences,
|
||||||
"version": version,
|
"version": version,
|
||||||
'own_acct': request.session.get('user', None),
|
'own_acct': request.session.get('user', None),
|
||||||
})
|
})
|
||||||
def privacy(request):
|
def privacy(request):
|
||||||
|
account, mastodon = get_usercontext(request)
|
||||||
return render(request, 'privacy.html',
|
return render(request, 'privacy.html',
|
||||||
{"fullbrutalism": fullbrutalism_p(request),
|
{"preferences": preferences,
|
||||||
'own_acct' : request.session.get('user', None)})
|
'own_acct' : request.session.get('user', None)})
|
||||||
|
|
||||||
@cache_page(60 * 30)
|
@cache_page(60 * 30)
|
||||||
@br_login_required
|
@br_login_required
|
||||||
def emoji_reference(request):
|
def emoji_reference(request):
|
||||||
mastodon = get_mastodon(request)
|
account, mastodon = get_usercontext(request)
|
||||||
emojos = mastodon.custom_emojis()
|
emojos = mastodon.custom_emojis()
|
||||||
return render(request, 'main/emoji.html',
|
return render(request, 'main/emoji.html',
|
||||||
{"fullbrutalism": fullbrutalism_p(request),
|
{"preferences": account.preferences,
|
||||||
"emojos": sorted(emojos, key=lambda x: x['shortcode']),
|
"emojos": sorted(emojos, key=lambda x: x['shortcode']),
|
||||||
'own_acct' : request.session['user']})
|
'own_acct' : request.session['user']})
|
||||||
|
|
Loading…
Reference in New Issue