feat: Implement warehouse module roles with auto-schema repair and remove module access section
- Add SchemaVerifier class for automatic database schema verification and repair - Implement warehouse_manager (Level 75) and warehouse_worker (Level 35) roles - Add zone-based access control for warehouse workers - Implement worker-manager binding system with zone filtering - Add comprehensive database auto-repair on Docker initialization - Remove Module Access section from user form (role-based access only) - Add autocomplete attributes to password fields for better UX - Include detailed documentation for warehouse implementation - Update initialize_db.py with schema verification as Step 0
This commit is contained in:
@@ -77,14 +77,100 @@
|
||||
<label for="role" class="form-label">Role <span class="text-danger">*</span></label>
|
||||
<select class="form-select" id="role" name="role" required>
|
||||
<option value="">-- Select a role --</option>
|
||||
{% for role in roles %}
|
||||
<option value="{{ role.name }}"
|
||||
{% if user and user.role == role.name %}selected{% endif %}>
|
||||
{{ role.name | capitalize }} (Level {{ role.level }})
|
||||
</option>
|
||||
{% endfor %}
|
||||
<optgroup label="System Roles">
|
||||
<option value="superadmin"
|
||||
{% if user and user.role == 'superadmin' %}selected{% endif %}>
|
||||
Super Admin (Level 100)
|
||||
</option>
|
||||
<option value="admin"
|
||||
{% if user and user.role == 'admin' %}selected{% endif %}>
|
||||
Admin (Level 90)
|
||||
</option>
|
||||
</optgroup>
|
||||
<optgroup label="Quality Module">
|
||||
<option value="manager"
|
||||
{% if user and user.role == 'manager' %}selected{% endif %}>
|
||||
Manager - Quality (Level 70)
|
||||
</option>
|
||||
<option value="worker"
|
||||
{% if user and user.role == 'worker' %}selected{% endif %}>
|
||||
Worker - Quality (Level 50)
|
||||
</option>
|
||||
</optgroup>
|
||||
<optgroup label="Warehouse Module">
|
||||
<option value="warehouse_manager"
|
||||
{% if user and user.role == 'warehouse_manager' %}selected{% endif %}>
|
||||
Manager - Warehouse (Level 75)
|
||||
</option>
|
||||
<option value="warehouse_worker"
|
||||
{% if user and user.role == 'warehouse_worker' %}selected{% endif %}>
|
||||
Worker - Warehouse (Level 35)
|
||||
</option>
|
||||
</optgroup>
|
||||
</select>
|
||||
<small class="form-text text-muted">User's access level</small>
|
||||
<small class="form-text text-muted">
|
||||
User's access level and role. See role descriptions below.
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 mb-3">
|
||||
<label class="form-label"><i class="fas fa-info-circle"></i> Role Reference Matrix</label>
|
||||
<div class="table-responsive" style="font-size: 0.9rem;">
|
||||
<table class="table table-sm table-bordered">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th style="width: 15%;">Role</th>
|
||||
<th style="width: 8%;">Level</th>
|
||||
<th style="width: 20%;">Modules</th>
|
||||
<th style="width: 57%;">Permissions & Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>Super Admin</strong></td>
|
||||
<td><span class="badge bg-danger">100</span></td>
|
||||
<td>All</td>
|
||||
<td>Unrestricted access to entire system. Can manage all users and configuration.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Admin</strong></td>
|
||||
<td><span class="badge bg-danger">90</span></td>
|
||||
<td>All</td>
|
||||
<td>Full system administration. Can manage users, settings, database, backups.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Manager - Quality</strong></td>
|
||||
<td><span class="badge bg-success">70</span></td>
|
||||
<td>Quality</td>
|
||||
<td>Create, edit, delete quality inspections. Can export and download quality reports.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Manager - Warehouse</strong></td>
|
||||
<td><span class="badge bg-success">75</span></td>
|
||||
<td>Warehouse</td>
|
||||
<td>Full warehouse input and analytics access. Can manage assigned warehouse workers and zones.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Worker - Quality</strong></td>
|
||||
<td><span class="badge bg-warning text-dark">50</span></td>
|
||||
<td>Quality</td>
|
||||
<td>Create and view quality inspections only. Cannot edit, delete, or view reports.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Worker - Warehouse</strong></td>
|
||||
<td><span class="badge bg-warning text-dark">35</span></td>
|
||||
<td>Warehouse</td>
|
||||
<td>Input pages only (set locations, create entries). <strong>No access to reports or analytics.</strong> Must be assigned to a Manager.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<small class="form-text text-muted d-block mt-2">
|
||||
<strong>Important:</strong> Warehouse workers are assigned to a manager for supervision.
|
||||
Quality and Warehouse modules are separate - users can have one or both module access.
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -94,7 +180,7 @@
|
||||
Password
|
||||
{% if not user %}<span class="text-danger">*</span>{% endif %}
|
||||
</label>
|
||||
<input type="password" class="form-control" id="password" name="password"
|
||||
<input type="password" class="form-control" id="password" name="password" autocomplete="new-password"
|
||||
{% if not user %}required{% else %}placeholder="Leave blank to keep current password"{% endif %}>
|
||||
<small class="form-text text-muted">
|
||||
{% if user %}Leave blank to keep current password{% else %}Minimum 8 characters{% endif %}
|
||||
@@ -105,34 +191,12 @@
|
||||
Confirm Password
|
||||
{% if not user %}<span class="text-danger">*</span>{% endif %}
|
||||
</label>
|
||||
<input type="password" class="form-control" id="confirm_password" name="confirm_password"
|
||||
<input type="password" class="form-control" id="confirm_password" name="confirm_password" autocomplete="new-password"
|
||||
{% if not user %}required{% endif %}>
|
||||
<small class="form-text text-muted">Re-enter password to confirm</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 mb-3">
|
||||
<label for="modules" class="form-label">Module Access <span class="text-danger">*</span></label>
|
||||
<div class="card bg-light">
|
||||
<div class="card-body">
|
||||
{% for module in available_modules %}
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="module_{{ module }}"
|
||||
name="modules" value="{{ module }}"
|
||||
{% if user and module in user_modules %}checked{% endif %}>
|
||||
<label class="form-check-label" for="module_{{ module }}">
|
||||
<i class="fas fa-{% if module == 'quality' %}check-square{% elif module == 'settings' %}sliders-h{% else %}cube{% endif %}"></i>
|
||||
{{ module | capitalize }} Module
|
||||
</label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<small class="form-text text-muted">Select which modules this user can access</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 mb-3">
|
||||
<label for="is_active" class="form-check-label">
|
||||
|
||||
Reference in New Issue
Block a user