Skip to content

Ublaze/AMC_Tracker1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

146 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AMC Tracker

A web application for tracking AMC (Annual Maintenance Contract) and license expiry dates for clients, with automated notification capabilities.

Features

  • Client Management: Add, edit, and manage client information
  • AMC Tracking: Track AMC start and end dates for each client
  • License Tracking: Track software license details including expiry dates
  • Notification System: Automated email notifications for expiring AMCs and licenses
  • Microsoft 365 Single Sign-On: Secure authentication using company Microsoft accounts
  • SendGrid Integration: Email notifications via SendGrid API
  • Responsive Design: Works on desktop and mobile devices

Technology Stack

  • Backend: Django 5.2
  • Frontend: Bootstrap 5, jQuery
  • Authentication: Microsoft Authentication Library (MSAL)
  • Email Service: SendGrid
  • Database: SQLite (default), can be configured for other databases

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd AMC_Tracker
    
  2. Create a virtual environment and activate it:

    python -m venv venv
    .\venv\Scripts\activate  # Windows
    source venv/bin/activate  # Linux/Mac
    
  3. Install dependencies:

    pip install -r requirements.txt
    
  4. Configure environment variables:

    • SENDGRID_API_KEY: Your SendGrid API key
    • DEFAULT_FROM_EMAIL: Default sender email for notifications
    • MSAL_CLIENT_ID: Microsoft application client ID
    • MSAL_CLIENT_SECRET: Microsoft application client secret
    • MSAL_REDIRECT_URI: Redirect URI for Microsoft authentication
  5. Run migrations:

    python manage.py migrate
    
  6. Create a superuser:

    python manage.py createsuperuser
    
  7. Run the development server:

    python manage.py runserver
    

Setting Up Scheduled Notifications

The AMC Tracker application includes a built-in notification system that automatically checks for and sends email notifications about expiring AMCs and licenses. The system:

  1. Uses HTML email templates for better-looking notifications
  2. Sends notifications for items expiring within 30 days
  3. Tracks notification status with the is_sent field
  4. Runs automatically through a middleware that checks if notifications need to be sent daily
  5. Stores the last run time in a JSON file to avoid sending duplicate notifications
  6. Avoids sending duplicate notifications by checking if a notification for the same client and item type has been sent within the notification threshold period

This implementation doesn't rely on external task schedulers or dependencies, making it suitable for both local and cloud hosting environments.

Manual Notification Check

You can also manually trigger notification checks by:

  1. Navigating to the Notification Settings page
  2. Clicking the "Check Notifications Now" button

Deployment

Heroku Deployment

  1. Create a Heroku account if you don't have one
  2. Install the Heroku CLI
  3. Login to Heroku:
    heroku login
    
  4. Create a new Heroku app:
    heroku create amc-tracker
    
  5. Add PostgreSQL add-on:
    heroku addons:create heroku-postgresql:hobby-dev
    
  6. Configure environment variables:
    heroku config:set SECRET_KEY=your-secret-key
    heroku config:set DEBUG=False
    heroku config:set SENDGRID_API_KEY=your-sendgrid-api-key
    heroku config:set DEFAULT_FROM_EMAIL=your-email@example.com
    heroku config:set MSAL_CLIENT_ID=your-microsoft-client-id
    heroku config:set MSAL_CLIENT_SECRET=your-microsoft-client-secret
    heroku config:set MSAL_REDIRECT_URI=https://your-app-name.herokuapp.com/auth/callback
    
  7. Deploy the application:
    git push heroku main
    
  8. Run migrations:
    heroku run python manage.py migrate
    
  9. Create a superuser:
    heroku run python manage.py createsuperuser
    

Other Deployment Options

The application can also be deployed to other platforms like:

  • AWS Elastic Beanstalk
  • DigitalOcean App Platform
  • PythonAnywhere
  • Railway

Make sure to configure the environment variables appropriately for your chosen platform.

Usage

  1. Access the admin interface at http://localhost:8000/admin/ to set up initial data
  2. Configure notification settings and SendGrid API details
  3. Add clients, AMCs, and licenses through the web interface
  4. The system will automatically send notifications for items expiring within the configured timeframe

Microsoft 365 Authentication Setup

  1. Register a new application in the Azure Portal
  2. Set the redirect URI to match your application's callback URL
  3. Grant the necessary permissions (User.Read, email, profile, openid)
  4. Update the environment variables with your application's credentials

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors