Files
TimeTracker/docker/test-permissions.py
Dries Peeters d230a41e8a feat: enhance web interface layout and fix logo import circular dependency
- Improve web interface layout for better user-friendliness and mobile responsiveness
  * Update CSS variables for consistent spacing and component sizing
  * Enhance card layouts with improved padding, borders, and shadows
  * Optimize button and form element dimensions for better touch targets
  * Add hover effects and animations for improved user interaction
  * Implement responsive grid system with mobile-first approach

- Refactor mobile JavaScript to prevent duplicate initialization
  * Consolidate mobile enhancements into dedicated utility classes
  * Add initialization guards to prevent double loading
  * Implement MobileUtils and MobileNavigation classes
  * Remove duplicate event listeners and mobile enhancements

- Fix circular import issue in logo handling
  * Replace problematic 'from app import app' with Flask's current_app
  * Add error handling for cases where current_app is unavailable
  * Improve logo path resolution with fallback mechanisms
  * Fix settings model to use proper Flask context

- Clean up template code and remove duplication
  * Remove duplicate mobile enhancements from base template
  * Clean up dashboard template JavaScript
  * Centralize all mobile functionality in mobile.js
  * Add proper error handling and debugging

- Update CSS variables and spacing system
  * Introduce --section-spacing and --card-spacing variables
  * Add mobile-specific spacing variables
  * Improve border-radius and shadow consistency
  * Enhance typography and visual hierarchy

This commit resolves the double loading issue and logo import errors while
significantly improving the overall user experience and mobile responsiveness
of the web interface.
2025-08-30 10:09:06 +02:00

130 lines
4.1 KiB
Python

#!/usr/bin/env python3
"""
Test script to check current permissions in Docker container
Run this to see what's wrong with the upload directories
"""
import os
import stat
import pwd
import grp
def get_user_info():
"""Get current user information"""
try:
uid = os.getuid()
gid = os.getgid()
user_info = pwd.getpwuid(uid)
group_info = grp.getgrgid(gid)
print(f"Current user: {user_info.pw_name}")
print(f"Current UID: {uid}")
print(f"Current GID: {gid}")
print(f"Current group: {group_info.gr_name}")
print(f"Current working directory: {os.getcwd()}")
return uid, gid
except Exception as e:
print(f"Error getting user info: {e}")
return 1000, 1000
def check_directory_permissions(path, description):
"""Check permissions for a specific directory"""
print(f"\n=== {description} ===")
print(f"Path: {path}")
if not os.path.exists(path):
print("✗ Directory does not exist")
return False
try:
# Get directory info
stat_info = os.stat(path)
mode = stat.filemode(stat_info.st_mode)
owner_uid = stat_info.st_uid
owner_gid = stat_info.st_gid
print(f"Permissions: {mode}")
print(f"Owner UID: {owner_uid}")
print(f"Owner GID: {owner_gid}")
# Try to get owner names
try:
owner_name = pwd.getpwuid(owner_uid).pw_name
print(f"Owner name: {owner_name}")
except:
print(f"Owner name: Unknown (UID {owner_uid})")
try:
group_name = grp.getgrgid(owner_gid).gr_name
print(f"Group name: {group_name}")
except:
print(f"Group name: Unknown (GID {owner_gid})")
# Check if current user can write
current_uid, current_gid = get_user_info()
can_write = False
if owner_uid == current_uid:
can_write = bool(stat_info.st_mode & stat.S_IWUSR)
print(f"Current user owns directory: {can_write}")
elif owner_gid == current_gid:
can_write = bool(stat_info.st_mode & stat.S_IWGRP)
print(f"Current user in owner group: {can_write}")
else:
can_write = bool(stat_info.st_mode & stat.S_IWOTH)
print(f"Current user has other write permission: {can_write}")
# Test write permission
test_file = os.path.join(path, 'test_permissions.tmp')
try:
with open(test_file, 'w') as f:
f.write('test')
os.remove(test_file)
print("✓ Write permission test: PASSED")
return True
except Exception as e:
print(f"✗ Write permission test: FAILED - {e}")
return False
except Exception as e:
print(f"Error checking directory: {e}")
return False
def main():
"""Main function"""
print("=== Docker Container Permission Test ===")
# Get current user info
current_uid, current_gid = get_user_info()
# Check upload directories
upload_dirs = [
("/app/app/static/uploads", "Main upload directory"),
("/app/app/static/uploads/logos", "Logo upload directory"),
("/app/static/uploads", "Alternative upload directory"),
("/app/static/uploads/logos", "Alternative logo directory")
]
all_passed = True
for path, description in upload_dirs:
if not check_directory_permissions(path, description):
all_passed = False
# Summary
print(f"\n=== Summary ===")
if all_passed:
print("✓ All permission tests passed!")
print("Upload directories should work correctly.")
else:
print("✗ Some permission tests failed!")
print("\nTo fix these issues:")
print("1. Rebuild the Docker container with the fixed Dockerfile")
print("2. Or run the permission fix script inside the container")
print("3. Or restart the container with proper volume permissions")
return all_passed
if __name__ == "__main__":
main()