Add barebones UI version tracking

This commit is contained in:
Tanner Collin 2022-01-21 22:48:51 +00:00
parent 69126440d3
commit cf79c335c2
3 changed files with 14 additions and 0 deletions

View File

@ -504,6 +504,7 @@ class UserSerializer(serializers.ModelSerializer):
transactions = serializers.SerializerMethodField() transactions = serializers.SerializerMethodField()
door_code = serializers.SerializerMethodField() door_code = serializers.SerializerMethodField()
wifi_pass = serializers.SerializerMethodField() wifi_pass = serializers.SerializerMethodField()
app_version = serializers.SerializerMethodField()
class Meta: class Meta:
model = User model = User
@ -517,6 +518,7 @@ class UserSerializer(serializers.ModelSerializer):
'is_staff', 'is_staff',
'door_code', 'door_code',
'wifi_pass', 'wifi_pass',
'app_version',
#'usages', #'usages',
] ]
depth = 1 depth = 1
@ -541,6 +543,9 @@ class UserSerializer(serializers.ModelSerializer):
else: else:
return None return None
def get_app_version(self, obj):
return settings.APP_VERSION
class MyRegisterSerializer(RegisterSerializer): class MyRegisterSerializer(RegisterSerializer):
first_name = serializers.CharField(max_length=32) first_name = serializers.CharField(max_length=32)

View File

@ -282,5 +282,7 @@ DEFAULT_FROM_EMAIL = 'Protospace Portal <portal@mg.protospace.ca>'
if DEBUG: logger.info('Debug mode ON') if DEBUG: logger.info('Debug mode ON')
logger.info('Test logging for each thread') logger.info('Test logging for each thread')
APP_VERSION = 1 # TODO: automate this
#import logging_tree #import logging_tree
#logging_tree.printout() #logging_tree.printout()

View File

@ -27,6 +27,8 @@ import { PasswordReset, ConfirmReset } from './PasswordReset.js';
import { NotFound, PleaseLogin } from './Misc.js'; import { NotFound, PleaseLogin } from './Misc.js';
import { Footer } from './Footer.js'; import { Footer } from './Footer.js';
const APP_VERSION = 1; // TODO: automate this
function App() { function App() {
const [token, setToken] = useState(localStorage.getItem('token', '')); const [token, setToken] = useState(localStorage.getItem('token', ''));
const [user, setUser] = useState(JSON.parse(localStorage.getItem('user', 'false'))); const [user, setUser] = useState(JSON.parse(localStorage.getItem('user', 'false')));
@ -98,6 +100,11 @@ function App() {
darkmode.showWidget(); darkmode.showWidget();
}, []); }, []);
if (user && user?.app_version !== APP_VERSION) {
setUserCache(false);
window.location.reload();
}
return ( return (
<div> <div>
<ManageScroll /> <ManageScroll />