link to my website: https://crm2-naq4z.ondigitalocean.app/
- Full featured CRM system
- Extend Authentication system: Login, Logout, Reset-Password
- Built-in signals dispatchers like – pre_save, post_save
- Uploading files options (Images and Documents)
- Only Class Based Views as well with the Forms
- Sending Email option ( inside the console)
- Filter results ( based on the user )
- Lead & Agent management under one organization:
- Create, View , Update and delete Lead / Agent
- Assign Each lead to Category and Agent
- Secured app both in backend and frontend
- Advance and flexible dashboards with analyses
- Combining the “flash message” feature
- Designed web app displays for users
- Customized admin site Interface
- Create your own virtual environment , and don't forget to activate it | toturial link
- Install all of the packages which is mentioned in
requirements.txt
file - Create a new file named
.env
inside the/core
folder ( must be in the/core
) - Copy all of the variables inside
core/.template.env
to your.env
file and fill your own values to them - Download Postgresql and configure the connection parameters with to your own db in
settings.py
, see link for tutorial for more explanation - Learn how to create your own
SECRET_KEY
: https://bit.ly/42atuj1 and copy it to.env
file - Create a superuser for your app (it will be used as the first user) run in the terminal
python manage.py createsuperuser
- Run
export READ_DOT_ENV_FILE=True
inside your terminal so that your environment variables file will be read. - Run
python manage.py makemigrations
inside your terminal - Run
python manage.py migrate
inside your terminal - After migrating, Run
python manage.py runserver
inside your terminal to run the server
If you have closely followed the instructions, you suppose the see the home html page and you can loging thesystem using the superuser credentials
In this project I have developed an advanced CRM app. The system manages two users types:
- Organizers
- Agents
Each type of user has a different level of permissions and those are enforced by using the Django authentication system. Under each Organizer there are several Agents. Under each Agent there are several leads:
Organisor The “Organizer” user is created right after a new user has registered the app. From the moment the Organiser user is created, a new UserProfile instance is also created. UserProfile is a model representing an Organisation, it has only one field, a ForeginKey field pointing to the User model, and it is attached to the Organiser User that has been created.
this is an example of three different organization using the same CRM system:
Any Agent and Lead has the “organization” field (pointing to the UserProfile model). And that separates Agents and Lead between the organizations in the system.
Each Organizer User has the permission to view and edit only leads and agents belonging to his organization. The same with agents: they have permissions to view Leads only from their organization that is attached to them.
As mentioned before, those permissions are enforced by using the Django Authentication system.
Agent: As was mentioned before, the Agent user has only the permission to view the leads attached to his organization . Agents can be edited (created, updated and deleted) only by an Organizer. Form the moment an agent is created, his email address is stored in the db and the agent can login the system only after completing the Resetting Password Via the “forgot password page”
Lead:
To make it clear: leads do not take part as a user in my app. They are only tracked by Agents and Organizer users. Leads can be classified to three kinds of fields:
- Organisation
- Agent
- Category As was mentioned previously, only an organizer can edit lead’s field.
A few words about combining the Django auth systme
Django authentication provides both authentication and authorization together and is generally referred to as the authentication system, as these features are somewhat coupled.
The authentication system of Django is mainly based on the User model, which I have customized a bit : adding the is_organisor and is_agent fields.
Login, Logout, Register, ResetPassword Moreover, Thanks to the following Django classes:
- LoginView
- SignUpView
- LogoutView
- PasswordResetView
- PasswordResetDoneView
- PasswordResetConfirmView
- PasswordResetCompleteView
I created the Login, Logout , Register and Reset Password functionalities. Those CBV( class based view ) gave me the tools to track each user who has sign to the app and send back HttpResponse objects based on their permissions.
Maintaining the security principles
Secure the Backend
my views were secure thanks to two django-built-in classes:
- OrganizorAndLoginRequiredMixin
- LoginRequiredMixin Each view inherit from one of those classes and thanks to that, user without permissions to a specific view will be redirect to the Login page or the leads list page.
Secure the Frontend In each HTML template I used the Django template (known as Jinja Engine) to Determine whether the user who sent the request has permission to access different links connecting to different views in my app.
using only Class Based View At the beginning it was a real challenge to learn how to use CBV with django. But after a while I got used to it and then learned the power behind using Abstract classes to handle different kinds of requests. The usage of forms in my app, the django authentication system, and each view are all based on classes and I am very proud of it.
The DataBase - PostgreSQL I learn how to connect my Django app to Postgresql - a much more scalable DB with much more benefits compare to the SQLITE:
- It has the ability to handle simultaneous access by multiple users.
- Has the ability to store nearly any type of data that you may need to store in your database.-
- Comes with many security features, which makes PostgreSQL a secure DBMS for the storage of sensitive and private data.
With those benefits come the Disadvantages: it is a complex DB and it might take much longer to configure it.
There is one positive thing about changing your DB in the Django project: once you configure the right db connection parameters, you can use Django the same as before, because the complex process of converting django syntax into sql queries is made behind the scene by Django engine that know how to create sql queries for different kinds of db. Thanks to that you can always change your DB with few customizations.
The distinction of my app comes in several aspects:
- Unlike the course, in my project I have used only class based views and not function base views
- Relational tables: some of my model’s fields have OneToOne relationship, some of them ManyToMany relationship and some of them OneToMany. To retrieve instances from different models I had to use those relationships to query instances from other tables.
- Ui interface is much more complex and well design:
- Business styled flat dashboard including forms, tables, charts, and modals.
- Light/Dark Sidebar Styles
- Well styled landing page
- Used the django crispy forms package to make each form in my website look better
- My project put a lot of attention on the security aspects, both in the frontend and backend sides. (I have already explained a lot about the django authentication system and how I used it.)
- My project involves new features: sending emails, signal dispatchers, FormValidation, Flash messages, Custom Domain Interface and many other things ( things new which we haven't learned in the course)
-
core/ where all of my projects file settings are located, including the .env file. In core/urls.py the main url paths are configured and other advanced url path configure in agents/urls.py and leads/urls.py
-
templates/: All of my templates are located in /template and all of the login,register,reset-password are located in /template/registration/
-
static/: my static files are located in /static but in production they are located in /static_root. the connection of all html files to a all of the static files is done thanks to the {% load static engine at the begining %}
-
leads/: a big portion of my project’s scripts are located in that folder. all of my models are located there, all of the views are written there (except the agent view). In leads/forms.py there are a bunch of forms classes that were written.
-
agent/ all the agent views are located in agents/view.py as well with the form agents/forms.py.