Role Manager is a web application designed to manage and assign roles within an organization or group. This application leverages Flask, SQLAlchemy, and jQuery to provide a responsive and interactive experience for managing role assignments and requests.
- Request roles with specific player information.
- Assign roles dynamically.
- Release roles when no longer needed.
- Display current roles and waiting queue.
- Asynchronous data fetching and rendering using jQuery.
role_manager/
├── __init__.py
├── app.py
├── config.py
├── create_app.py
├── models.py
├── role_manager.py
├── routes/
│ ├── __init__.py
│ ├── main_routes.py
│ ├── role_routes.py
├── static/
├── templates/
│ ├── base.html
│ ├── index.html
__init__.py
: Marks the directory as a Python package.app.py
: Entry point for running the Flask application.config.py
: Contains configuration settings for the Flask application.create_app.py
: Factory function to create and configure the Flask application.models.py
: Defines database models using SQLAlchemy.role_manager.py
: Contains theRoleManager
class for managing roles.routes/__init__.py
: Initializes and registers routes with the Flask application.routes/main_routes.py
: Contains the main application routes.routes/role_routes.py
: Contains routes for role-related operations.static/
: Directory for static files like CSS and JavaScript.templates/
: Directory for HTML templates.
- Python 3.8 or later
- Virtualenv (optional but recommended)
- SQLite (default database)
-
Clone the Repository
git clone https://github.com/blackms/role_manager.git cd role_manager
-
Create and Activate Virtual Environment
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts�ctivate`
-
Install Dependencies
pip install -r requirements.txt
-
Configure Environment Variables
Create a
.env
file in the project root and set the necessary environment variables.FLASK_APP=app.py FLASK_ENV=development SECRET_KEY=your_secret_key DATABASE_URL=sqlite:///app.db
-
Initialize the Database
flask db init flask db migrate flask db upgrade
-
Run the Application
flask run
The application should now be running at
http://127.0.0.1:5000
.
The create_app
function sets up the Flask application, configures the database, and registers blueprints.
Defines the RoleRequest
model with fields for alliance
, player
, role
, coordinates
, request_time
, and status
.
Contains the RoleManager
class that handles role requests, assignments, and releases.
Registers the route blueprints with the Flask application.
Contains routes for handling role requests, assignments, and releases, and serves JSON data for asynchronous operations.
Uses jQuery to asynchronously fetch and display data. Handles form submissions for role requests and updates the DOM dynamically.
-
Start the Flask Development Server
flask run
-
Access the Application
Open a web browser and navigate to
http://127.0.0.1:5000
.
-
Requesting a Role
Fill out the form on the home page to request a role. The request is handled by the
/request_role
endpoint and updates the waiting queue. -
Assigning a Role
Click the "Assign" button next to a role to assign it to the next request in the queue. The assignment is handled by the
/assign_role/<role>
endpoint. -
Releasing a Role
Click the "Release" button next to an assigned role to release it. The release is handled by the
/release_role/<role>
endpoint.
-
Fork the Repository
-
Create a Branch
git checkout -b feature/your-feature
-
Commit Your Changes
git commit -m "Add your feature"
-
Push to the Branch
git push origin feature/your-feature
-
Open a Pull Request
This project is licensed under the MIT License.
By following this guide, you should be able to set up, run, and understand the Role Manager application. If you encounter any issues or have further questions, please consult the project's documentation or open an issue on the GitHub repository.