mirror of
http://git.carcosa.net/jmcbray/brutaldon.git
synced 2024-11-23 07:13:52 -05:00
Store instance version in the client table
It is updated on new login, on entering the settings page, and on timeline load. The last may be too often, but I thought the other two were not often enough.
This commit is contained in:
parent
21da39c422
commit
4de237a1b5
18
brutaldon/migrations/0021_client_version.py
Normal file
18
brutaldon/migrations/0021_client_version.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 2.1.5 on 2019-04-29 18:37
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('brutaldon', '0020_auto_20190127_2159'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='client',
|
||||
name='version',
|
||||
field=models.CharField(default='1.0', max_length=8),
|
||||
),
|
||||
]
|
@ -8,6 +8,7 @@ timezones = [(tz, tz) for tz in common_timezones]
|
||||
class Client(models.Model):
|
||||
name = models.CharField(default = "brutaldon", max_length=80)
|
||||
api_base_id = models.URLField(default="https://mastodon.social")
|
||||
version = models.CharField(default="1.0", max_length=8)
|
||||
client_id = models.CharField(null=True, blank=True, max_length=2048)
|
||||
client_secret = models.CharField(null=True, blank=True, max_length=2048)
|
||||
|
||||
|
@ -304,6 +304,8 @@ def login(request):
|
||||
client_id = client.client_id,
|
||||
client_secret = client.client_secret,
|
||||
api_base_url = api_base_url)
|
||||
client.version = mastodon.instance().get("version")
|
||||
client.save()
|
||||
return redirect(mastodon.auth_request_url(redirect_uris=redirect_uris,
|
||||
scopes=['read', 'write', 'follow']))
|
||||
else:
|
||||
@ -394,6 +396,8 @@ def old_login(request):
|
||||
client_id = client.client_id,
|
||||
client_secret = client.client_secret,
|
||||
api_base_url = api_base_url)
|
||||
client.version = mastodon.instance().get("version")
|
||||
client.save()
|
||||
|
||||
try:
|
||||
account = Account.objects.get(email=email, client_id=client.id)
|
||||
@ -545,6 +549,9 @@ def user(request, username, prev=None, next=None):
|
||||
def settings(request):
|
||||
try:
|
||||
account, mastodon = get_usercontext(request)
|
||||
account.client.version = mastodon.instance().get("version")
|
||||
account.client.save()
|
||||
|
||||
except NotLoggedInException:
|
||||
return redirect(about)
|
||||
if request.method == 'POST':
|
||||
|
Loading…
Reference in New Issue
Block a user