A comprehensive management system for mosques, built with Django and Wagtail.
- Membership Management: Track families, members, and vital records (Nikah, Janazah, etc.).
- Finance: Manage donations, expenses, and membership dues.
- Education: Manage classes, teachers, and student enrollments.
- Operations: Prayer times, auditorium bookings, and digital signage.
- Home/Dashboard: Executive dashboard with key metrics.
The system categorizes users into several roles across different modules:
Primary roles for dashboard and module management:
- Administrator: Full system access.
- Executive Board Member: High-level oversight and reporting.
- Department Manager: Specific module management (Finance, HR, etc.).
- Staff Member: Standard operational access.
- Volunteer: Restricted access for specific tasks.
Specific roles for mosque employees:
- Imam / Assistant Imam
- Muazzin
- Teacher
- Administrator
- Maintenance / Cleaner
- Security Guard
Leadership and governance roles:
- Trustees: President, Vice President, Secretary, Treasurer.
- Committee: Chairperson, Secretary, Minute Taker.
Follow these steps to set up the project on a new machine.
- Python 3.10+
- Git
git clone <repository-url>
cd mms_v1macOS / Linux:
python3 -m venv .venv
source .venv/bin/activateWindows:
python -m venv .venv
.venv\Scripts\activatepip install -r requirements.txtThe project uses django-environ for configuration. Create a .env file in the project root:
cp .env.example .env # Or create it manuallyUpdate your .env with your local database credentials.
The system uses PostgreSQL for both local development and production. It supports switching between multiple database environments (e.g., local-dev, remote-dev1).
1. Configure Database Credentials:
Update DATABASE_URL in .env for your local database:
DATABASE_URL=postgres://postgres:Password1!@127.0.0.1:5432/mms_v12. Switching Environments:
The application defaults to local-dev. To switch to a different database (e.g., remote-dev1), set the SELECTED_DATABASE environment variable in your .env file or shell:
# In .env file
SELECTED_DATABASE=remote-dev13. Apply Migrations: Ensure you apply migrations to the selected database:
# Example: Apply migrations to the currently selected database (from .env)
python manage.py migrate
# Example: One-off command for a specific database
SELECTED_DATABASE=remote-dev1 python manage.py migrate4. MySQL Configuration (Optional): To use MySQL instead of PostgreSQL:
-
Install MySQL server and create a database:
CREATE DATABASE mms_v1 CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-
Add
MYSQL_DB_URLto your.envfile:MYSQL_DB_URL=mysql://username:password@localhost:3306/mms_v1
-
Switch to MySQL by setting:
SELECTED_DATABASE=mysql-dev
-
Install the MySQL client library:
pip install mysqlclient
Seed Sample Data:
python manage.py populate_sample_dataWhen you make changes to models, you need to create and apply migrations to update your database schema.
1. Create Migrations: Generate migration files based on your model changes:
python manage.py makemigrations2. Apply Migrations: Apply the generated migrations to the selected database:
python manage.py migrate3. Check Status (Optional): To see which migrations have been applied:
python manage.py showmigrations# Superuser credentials are pre-configured if using sample data:
# Username: admin / Password: adminpassword
python manage.py createsuperuser # To create a new onepython manage.py runserverFor detailed instructions on deploying to Google Cloud Run and Cloud SQL, refer to the walkthrough.md.
# 1) Pull latest code
git pull
# 2) Activate venv
source ~/.virtualenvs/<your-venv-name>/bin/activate
eg:- source /home/shajeebsh/.virtualenvs/.env/bin/activate
# 3) Install deps (if changed)
pip install -r requirements.txt
# 4) Apply DB migrations
python manage.py migrate
# 5) Static files
python manage.py collectstatic --noinputThen go to the Web tab in PythonAnywhere and click Reload.
- Website: http://127.0.0.1:8000
- Admin Panel: http://127.0.0.1:8000/cms/
The project includes comprehensive test suites for models, views, and business logic. Here's how to run them:
python manage.py test# Run all membership tests
python manage.py test membership
# Run all finance tests
python manage.py test finance# Run model tests
python manage.py test membership.tests
# Run view integration tests
python manage.py test membership.test_views
# Run business logic tests
python manage.py test membership.test_business_logic# Run a specific test class
python manage.py test membership.tests.FamilyModelTest
# Run a specific test method
python manage.py test membership.tests.FamilyModelTest.test_family_creationVerbose Output (recommended for seeing test details):
python manage.py test membership --verbosity=2Keep Test Database (faster for repeated test runs):
python manage.py test membership --keepdbRun Tests in Parallel (faster execution):
python manage.py test membership --parallelRun Tests with Coverage (if coverage.py is installed):
coverage run --source='.' manage.py test membership
coverage report
coverage html # Generates HTML report in htmlcov/The test suite includes:
- Unit Tests (
membership/tests.py,finance/tests.py): Test individual model functionality, validations, and properties - Integration Tests (
membership/test_views.py): Test view functionality, HTTP requests, and user interactions - Business Logic Tests (
membership/test_business_logic.py): Test critical business logic like payment processing and dues calculations - Automated E2E Tests (
tests/e2e/): Browser-based testing using Playwright and Pytest
The system includes automated browser tests for end-to-end verification covering CRUD operations for all major modules:
- Membership (Families, Members)
- Finance (Donations, Expenses)
- Accounting (Chart of Accounts, Ledger)
- Billing (Invoices, Payments)
- Education (Teachers, Classes)
- Assets (Shops, Property Units)
- Operations (Bookings, Prayer Times)
- HR (Staff, Positions)
- Committee (Committees, Trustees)
- Sample Data
-
Install Test Dependencies:
pip install pytest-playwright playwright install chromium
-
Run E2E Tests: Ensure the development server is running in another terminal (
python manage.py runserver), then run the full suite:pytest tests/e2e/
Or run specific module tests:
pytest tests/e2e/test_membership.py pytest tests/e2e/test_finance.py # ...and so on for other modules
To generate a comprehensive HTML report of the test results:
pytest tests/e2e/ --html=report.htmlThis will create a report.html file in the project directory which you can open in your browser.
- Membership Dues: Go to Settings > System settings in the admin panel to configure the default monthly dues amount.
-
Start the development server:
python manage.py runserver
-
Create a Non-member Donation:
- Go to CMS admin:
http://localhost:8000/cms/ - Navigate to Finance > Donations > Add New Donation
- Leave the "Member" field blank
- Enter a name in the "Donor Name" field (e.g., "John Smith")
- Fill in amount, category, donation type, and date
- Save the donation
- Verify the donation appears in the list with the donor name displayed
- Go to CMS admin:
-
Create a Member Donation:
- Add another donation but select a Member from the dropdown
- Leave "Donor Name" blank
- Save and verify the member's name is displayed in the list
-
Verify Donation List Display:
- Go to Finance > Donations
- Confirm both member and non-member donations display correctly
- Search for the non-member donor name to verify search functionality
-
Setup Test Data (if not already present):
- Create a Class with a course fee (Education > Classes > Add)
- Enroll a student in the class (Education > Student Enrollments > Add)
- Set payment status to "Pending" or "Partial"
-
View Pending Fees Report:
- Navigate to Education > Pending Course Fees
- Verify student names display correctly in the table
- Check that the following columns show proper data:
- Student Name (should show full name, not object reference)
- Class name
- Total Fee, Paid amount, Balance
- Payment status (Pending/Partial)
- Contact phone number
-
Test with Partial Payment:
- Add a fee payment for a student (Education > Student Fee Payments > Add)
- Pay less than the total course fee
- Refresh the Pending Fees report
- Verify the student shows "Partial" status with updated Paid and Balance amounts
-
Test Full Payment:
- Add another payment to complete the full fee
- Verify the student no longer appears in the Pending Fees report