auto-claude: subtask-1-1 - Grant admin rights to Artur Wiertel (WATERM)

Created migration script grant_admin_artur_wiertel.py that:
- Finds user by company_id=12 (WATERM)
- Sets is_admin=True for the user
- Supports --dry-run mode for verification
- Includes error handling and rollback

To deploy: Run script on production server with www-data user.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-01-06 21:58:33 +01:00
parent 02fc67bf40
commit 0e9d912a1b
3 changed files with 180 additions and 0 deletions

View File

@ -0,0 +1,41 @@
# Build Progress: Admin Rights for Artur Wiertel
## Status: READY FOR DEPLOYMENT
### Completed Tasks
- [x] **subtask-1-1**: Created migration script `grant_admin_artur_wiertel.py`
- Script finds user by company_id=12 (WATERM)
- Sets is_admin=True
- Supports --dry-run for verification
- Safe rollback on errors
### Deployment Instructions
1. SSH to production server:
```bash
ssh maciejpi@10.22.68.249
```
2. Copy script to production:
```bash
scp grant_admin_artur_wiertel.py maciejpi@10.22.68.249:/var/www/nordabiznes/
```
3. Run script (dry-run first):
```bash
cd /var/www/nordabiznes
sudo -u www-data ./venv/bin/python3 grant_admin_artur_wiertel.py --dry-run
```
4. If dry-run looks correct, execute:
```bash
sudo -u www-data ./venv/bin/python3 grant_admin_artur_wiertel.py
```
### Manual Verification
After running the script:
1. Ask Artur Wiertel to log in at https://nordabiznes.pl/login
2. Verify he can access /admin/news panel
3. Verify he can moderate news items

View File

@ -0,0 +1,41 @@
{
"feature": "admin-rights-artur-wiertel",
"workflow_type": "simple",
"total_phases": 1,
"recommended_workers": 1,
"phases": [
{
"phase": 1,
"name": "Grant Admin Privileges",
"description": "Set is_admin=True for Artur Wiertel's user account",
"depends_on": [],
"subtasks": [
{
"id": "subtask-1-1",
"description": "Update user record to set is_admin=True for Artur Wiertel (WATERM owner, company_id=12)",
"service": "database",
"status": "completed",
"files_to_create": [],
"files_to_modify": [],
"database_changes": [
"UPDATE users SET is_admin = TRUE WHERE company_id = 12"
],
"patterns_from": [],
"verification": {
"type": "manual",
"run": "Login as Artur Wiertel and verify access to /admin/news"
},
"notes": "Created grant_admin_artur_wiertel.py script that safely updates is_admin=True for WATERM owner (company_id=12). Script supports --dry-run mode and includes error handling.",
"updated_at": "2026-01-06T20:58:16.509339+00:00"
}
]
}
],
"metadata": {
"created_at": "2026-01-06",
"complexity": "simple",
"estimated_sessions": 1,
"notes": "Database-only change, no code modifications needed"
},
"last_updated": "2026-01-06T20:58:16.509348+00:00"
}

View File

@ -0,0 +1,98 @@
#!/usr/bin/env python3
"""
Grant admin rights to Artur Wiertel (WATERM owner, company_id=12)
This script updates the is_admin field to True for the user associated
with WATERM company.
Usage:
python grant_admin_artur_wiertel.py [--dry-run]
Options:
--dry-run Show what would be changed without making changes
"""
import sys
from database import SessionLocal, User, Company
def grant_admin_to_waterm_owner(dry_run=False):
"""Grant admin rights to WATERM owner (company_id=12)"""
session = SessionLocal()
try:
# First, verify the company exists
company = session.query(Company).filter(Company.id == 12).first()
if not company:
print("❌ Error: Company with id=12 not found")
return False
print(f"✅ Found company: {company.name} (NIP: {company.nip})")
# Find the user associated with this company
user = session.query(User).filter(User.company_id == 12).first()
if not user:
print(f"❌ Error: No user found for company_id=12 ({company.name})")
print(" Please ensure the user account exists before granting admin rights.")
return False
print(f"✅ Found user: {user.name} ({user.email})")
print(f" Current admin status: {user.is_admin}")
if user.is_admin:
print(" User already has admin rights. No changes needed.")
return True
if dry_run:
print("\n[DRY RUN] Would set is_admin=True for this user")
print("[DRY RUN] No changes made to database")
return True
# Grant admin rights
user.is_admin = True
session.commit()
print(f"\n✅ Successfully granted admin rights to {user.name}")
print(f" Email: {user.email}")
print(f" Company: {company.name}")
print(f" Admin status: {user.is_admin}")
return True
except Exception as e:
session.rollback()
print(f"❌ Error: {e}")
return False
finally:
session.close()
def main():
dry_run = '--dry-run' in sys.argv
print("=" * 60)
print("Grant Admin Rights - Artur Wiertel (WATERM)")
print("=" * 60)
if dry_run:
print("\n🔍 DRY RUN MODE - No changes will be made\n")
success = grant_admin_to_waterm_owner(dry_run=dry_run)
if success:
print("\n✅ Operation completed successfully")
if not dry_run:
print("\nNext steps:")
print("1. Ask Artur to log in at https://nordabiznes.pl/login")
print("2. Verify access to /admin/news panel")
return 0
else:
print("\n❌ Operation failed")
return 1
if __name__ == '__main__':
sys.exit(main())