Prepare for superuser Git revision display
This commit is contained in:
parent
1c0a12c881
commit
32bde8ee00
4 changed files with 34 additions and 1 deletions
11
manager/cronjobs.py
Normal file
11
manager/cronjobs.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
from git import Repo
|
||||
from django_cron import CronJobBase, Schedule
|
||||
from django.conf import settings
|
||||
|
||||
class FetchRemoteCron(CronJobBase):
|
||||
schedule = Schedule(run_every_mins=5)
|
||||
code = "manager.fetchremotecron"
|
||||
|
||||
def do(self):
|
||||
repo = Repo(settings.BASE_DIR)
|
||||
repo.remotes[0].fetch()
|
15
manager/templatetags/repo.py
Normal file
15
manager/templatetags/repo.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
from django import template
|
||||
from django.conf import settings
|
||||
from git import Repo
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@register.simple_tag
|
||||
def getCommit():
|
||||
repo = Repo(settings.BASE_DIR)
|
||||
return "%s (%s)" % (str(repo.head.commit)[:7], str(repo.head.commit.committed_datetime))
|
||||
|
||||
def isLatestCommit():
|
||||
repo = Repo(settings.BASE_DIR)
|
||||
origin = repo.remotes[0].refs[0]
|
||||
return origin.commit.committed_datetime <= repo.head.commit.committed_datetime
|
2
setup.sh
2
setup.sh
|
@ -2,7 +2,7 @@
|
|||
|
||||
sudo apt update
|
||||
sudo apt install -y python3-pip npm openvpn easy-rsa postfix
|
||||
sudo pip3 install -U django uwsgi django-two-factor-auth django-bootstrap-form twilio argon2_cffi
|
||||
sudo pip3 install -U django django-cron uwsgi django-two-factor-auth django-bootstrap-form twilio argon2_cffi GitPython
|
||||
sudo useradd vpn
|
||||
git submodule init
|
||||
git submodule update
|
||||
|
|
|
@ -33,6 +33,7 @@ INSTALLED_APPS = [
|
|||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'manager.apps.ManagerConfig',
|
||||
'django_cron',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
@ -134,3 +135,9 @@ PASSWORD_HASHERS = [
|
|||
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
|
||||
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
|
||||
]
|
||||
|
||||
# Cron Jobs
|
||||
|
||||
CRON_CLASSES = [
|
||||
"manager.cronjobs.FetchRemoteCron",
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue