mirror of
https://github.com/house-of-vanity/OutFleet.git
synced 2025-07-06 09:04:07 +00:00
Fixed text search fileds for ACL and Logs. Added version info to footer.
This commit is contained in:
17
.github/workflows/main.yml
vendored
17
.github/workflows/main.yml
vendored
@ -24,13 +24,26 @@ jobs:
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Set outputs
|
||||
id: vars
|
||||
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
run: |
|
||||
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
echo "sha_full=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
|
||||
echo "build_date=$(date -u +'%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_OUTPUT
|
||||
echo "branch_name=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
|
||||
- name: Check outputs
|
||||
run: echo ${{ steps.vars.outputs.sha_short }}
|
||||
run: |
|
||||
echo "Short SHA: ${{ steps.vars.outputs.sha_short }}"
|
||||
echo "Full SHA: ${{ steps.vars.outputs.sha_full }}"
|
||||
echo "Build Date: ${{ steps.vars.outputs.build_date }}"
|
||||
echo "Branch: ${{ steps.vars.outputs.branch_name }}"
|
||||
-
|
||||
name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
build-args: |
|
||||
GIT_COMMIT=${{ steps.vars.outputs.sha_full }}
|
||||
GIT_COMMIT_SHORT=${{ steps.vars.outputs.sha_short }}
|
||||
BUILD_DATE=${{ steps.vars.outputs.build_date }}
|
||||
BRANCH_NAME=${{ steps.vars.outputs.branch_name }}
|
||||
tags: ultradesu/outfleet:v2,ultradesu/outfleet:${{ steps.vars.outputs.sha_short }}
|
||||
|
13
Dockerfile
13
Dockerfile
@ -1,5 +1,17 @@
|
||||
FROM python:3-alpine
|
||||
|
||||
# Build arguments
|
||||
ARG GIT_COMMIT="development"
|
||||
ARG GIT_COMMIT_SHORT="dev"
|
||||
ARG BUILD_DATE="unknown"
|
||||
ARG BRANCH_NAME="unknown"
|
||||
|
||||
# Environment variables from build args
|
||||
ENV GIT_COMMIT=${GIT_COMMIT}
|
||||
ENV GIT_COMMIT_SHORT=${GIT_COMMIT_SHORT}
|
||||
ENV BUILD_DATE=${BUILD_DATE}
|
||||
ENV BRANCH_NAME=${BRANCH_NAME}
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY ./requirements.txt .
|
||||
@ -7,5 +19,4 @@ RUN apk update && apk add git && pip install --no-cache-dir -r requirements.txt
|
||||
COPY . .
|
||||
RUN python manage.py collectstatic --noinput
|
||||
|
||||
|
||||
CMD [ "python", "./manage.py", "runserver", "0.0.0.0:8000" ]
|
||||
|
42
mysite/context_processors.py
Normal file
42
mysite/context_processors.py
Normal file
@ -0,0 +1,42 @@
|
||||
from django.conf import settings
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
def version_info(request):
|
||||
"""Add version information to template context"""
|
||||
|
||||
git_commit = getattr(settings, 'GIT_COMMIT', None)
|
||||
git_commit_short = getattr(settings, 'GIT_COMMIT_SHORT', None)
|
||||
build_date = getattr(settings, 'BUILD_DATE', None)
|
||||
|
||||
if not git_commit or git_commit == 'development':
|
||||
try:
|
||||
base_dir = getattr(settings, 'BASE_DIR', Path(__file__).resolve().parent.parent)
|
||||
result = subprocess.run(['git', 'rev-parse', 'HEAD'],
|
||||
capture_output=True, text=True, cwd=base_dir, timeout=5)
|
||||
if result.returncode == 0:
|
||||
git_commit = result.stdout.strip()
|
||||
git_commit_short = git_commit[:7]
|
||||
|
||||
date_result = subprocess.run(['git', 'log', '-1', '--format=%ci'],
|
||||
capture_output=True, text=True, cwd=base_dir, timeout=5)
|
||||
if date_result.returncode == 0:
|
||||
build_date = date_result.stdout.strip()
|
||||
except (subprocess.TimeoutExpired, subprocess.SubprocessError, FileNotFoundError):
|
||||
pass
|
||||
|
||||
if not git_commit:
|
||||
git_commit = 'development'
|
||||
if not git_commit_short:
|
||||
git_commit_short = 'dev'
|
||||
if not build_date:
|
||||
build_date = 'unknown'
|
||||
|
||||
return {
|
||||
'VERSION_INFO': {
|
||||
'git_commit': git_commit,
|
||||
'git_commit_short': git_commit_short,
|
||||
'build_date': build_date,
|
||||
'is_development': git_commit_short == 'dev'
|
||||
}
|
||||
}
|
@ -120,6 +120,10 @@ MIDDLEWARE = [
|
||||
|
||||
ROOT_URLCONF = 'mysite.urls'
|
||||
|
||||
GIT_COMMIT = ENV('GIT_COMMIT', default='development')
|
||||
GIT_COMMIT_SHORT = ENV('GIT_COMMIT_SHORT', default='dev')
|
||||
BUILD_DATE = ENV('BUILD_DATE', default='unknown')
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
@ -131,11 +135,13 @@ TEMPLATES = [
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'mysite.context_processors.version_info',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
WSGI_APPLICATION = 'mysite.wsgi.application'
|
||||
|
||||
|
||||
|
@ -125,7 +125,7 @@ class UserAdmin(admin.ModelAdmin):
|
||||
class AccessLogAdmin(admin.ModelAdmin):
|
||||
list_display = ('user', 'server', 'action', 'formatted_timestamp')
|
||||
list_filter = ('user', 'server', 'action', 'timestamp')
|
||||
search_fields = ('user', 'server', 'action', 'timestamp')
|
||||
search_fields = ('user', 'server', 'action', 'timestamp', 'data')
|
||||
readonly_fields = ('server', 'user', 'formatted_timestamp', 'action', 'formated_data')
|
||||
|
||||
@admin.display(description='Timestamp')
|
||||
@ -161,7 +161,8 @@ class ACLAdmin(admin.ModelAdmin):
|
||||
|
||||
list_display = ('user', 'server', 'server_type', 'display_links', 'created_at')
|
||||
list_filter = (UserNameFilter, 'server__server_type', ServerNameFilter)
|
||||
search_fields = ('user__name', 'server__name', 'server__comment', 'user__comment', 'links__link')
|
||||
# Fixed search_fields - removed problematic polymorphic server fields
|
||||
search_fields = ('user__username', 'user__comment', 'links__link')
|
||||
readonly_fields = ('user_info',)
|
||||
inlines = [ACLLinkInline]
|
||||
|
||||
@ -184,4 +185,3 @@ class ACLAdmin(admin.ModelAdmin):
|
||||
links = obj.links.all()
|
||||
formatted_links = [f"{link.comment} - {EXTERNAL_ADDRESS}/ss/{link.link}#{link.acl.server.name}" for link in links]
|
||||
return mark_safe('<br>'.join(formatted_links))
|
||||
|
||||
|
37
vpn/templates/admin/base_site.html
Normal file
37
vpn/templates/admin/base_site.html
Normal file
@ -0,0 +1,37 @@
|
||||
{% extends "admin/base.html" %}
|
||||
|
||||
{% block title %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %}
|
||||
|
||||
{% block branding %}
|
||||
<h1 id="site-name"><a href="{% url 'admin:index' %}">{{ site_header|default:_('Django administration') }}</a></h1>
|
||||
{% endblock %}
|
||||
|
||||
{% block footer %}
|
||||
<div id="footer" style="margin-top: 20px; padding: 10px; border-top: 1px solid #ccc; font-size: 12px; color: #666;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center;">
|
||||
<div>
|
||||
<strong>OutFleet VPN Manager</strong>
|
||||
</div>
|
||||
<div style="text-align: right;">
|
||||
{% if VERSION_INFO %}
|
||||
<div>
|
||||
<strong>Version:</strong>
|
||||
<code>{{ VERSION_INFO.git_commit_short }}</code>
|
||||
{% if VERSION_INFO.is_development %}
|
||||
<span style="color: #e74c3c;">(Development)</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if not VERSION_INFO.is_development %}
|
||||
<div style="margin-top: 2px;">
|
||||
<strong>Built:</strong> {{ VERSION_INFO.build_date }}
|
||||
</div>
|
||||
<div style="margin-top: 2px;">
|
||||
<strong>Commit:</strong>
|
||||
<code style="font-size: 10px;">{{ VERSION_INFO.git_commit }}</code>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
Reference in New Issue
Block a user