-
Notifications
You must be signed in to change notification settings - Fork 282
Design Document
Jayesh Lahori edited this page Aug 13, 2014
·
14 revisions
I have Django Project called VMS
and AdminUnit
as an app inside VMS
.
Following are the file's inside AdminUnit app.
- models.py - Contains all tables associated with the app
- forms.py - Contains forms which have been used throughout to enter data into the system. Some of them inherit the ModelForm class of Django which helps directly create a form from Django Models, Other's inherit forms.Form class
- admin.py - Contains views to be shown in admin
- tests.py - Contains unit-tests to test the model structures and Client tests to test the views.
- urls.py - Contains mapping of url's to view methods
- views.py - Contains methods for displaying views
Following are the models currently used in AdminUnit.
- Organization - This table stores the information about various organization's which are registered ABI. Volunteers/Admins also have an associated organization field in their Profile.
CREATE TABLE "AdminUnit_organization" (
"id" serial NOT NULL PRIMARY KEY,
"name" varchar(128) NOT NULL UNIQUE,
"location" varchar(128) NOT NULL,
"noOfVolunteers" integer NOT NULL
);
```
* **AdminProfile** - All users who will be given admin access to the system will be registered into this table. This table has a One-to-one relationship with Django's `auth` table.
```
CREATE TABLE "AdminUnit_adminprofile" (
"id" serial NOT NULL PRIMARY KEY,
"user_id" integer NOT NULL UNIQUE REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED,
"address" varchar(128) NOT NULL,
"location" varchar(128) NOT NULL,
"state" varchar(128) NOT NULL,
"organization_id" integer NOT NULL REFERENCES "AdminUnit_organization" ("id") DEFERRABLE INITIALLY DEFERRED,
"phone" varchar(128) NOT NULL
);
```
* **VolunteerProfile** - All volunteers will be registered in this table. This table will also have one-to-one relationship with `auth` table. **Note** : This model will be replaced by Irish's volunteer model while integration. Currently, its structure is same as AdminProfile.
```
CREATE TABLE "AdminUnit_volunteerprofile" (
"id" serial NOT NULL PRIMARY KEY,
"user_id" integer NOT NULL UNIQUE REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED,
"address" varchar(128) NOT NULL,
"location" varchar(128) NOT NULL,
"state" varchar(128) NOT NULL,
"organization_id" integer NOT NULL REFERENCES "AdminUnit_organization" ("id") DEFERRABLE INITIALLY DEFERRED,
"phone" varchar(128) NOT NULL
);
```
* **Event** - This table holds information regarding various events which will be created by admins. Eg: GSOC-2014 is an event extending from April-14 to Aug-14.
```
CREATE TABLE "AdminUnit_event" (
"id" serial NOT NULL PRIMARY KEY,
"eventName" varchar(128) NOT NULL UNIQUE,
"noOfVolunteersRequired" integer NOT NULL,
"startDate" timestamp with time zone NOT NULL,
"endDate" timestamp with time zone NOT NULL
);
```
* **Job** - This table holds information regarding various jobs which will be created inside an event. Eg: Mentoring is a job inside GSOC-2014 event similar is Org-admin.
```
CREATE TABLE "AdminUnit_job" (
"id" serial NOT NULL PRIMARY KEY,
"event_id" integer NOT NULL REFERENCES "AdminUnit_event" ("id") DEFERRABLE INITIALLY DEFERRED,
"jobName" varchar(128) NOT NULL,
"jobDescription" varchar(256) NOT NULL,
"startDate" timestamp with time zone NOT NULL,
"endDate" timestamp with time zone NOT NULL,
"noOfVolunteersRequired" integer NOT NULL,
UNIQUE ("event_id", "jobName")
);
```
* **Shift** - This table acts like a store to store data points of the form `<event, job, volunteer, hours>` . Whenever an admin assigns a job to a volunteer or a volunteer opts for a job, The entry gets created here
```
CREATE TABLE "AdminUnit_shift" (
"id" serial NOT NULL PRIMARY KEY,
"event_id" integer NOT NULL REFERENCES "AdminUnit_event" ("id") DEFERRABLE INITIALLY DEFERRED,
"volunteer_id" integer NOT NULL REFERENCES "AdminUnit_volunteerprofile" ("id") DEFERRABLE INITIALLY DEFERRED,
"job_id" integer NOT NULL REFERENCES "AdminUnit_job" ("id") DEFERRABLE INITIALLY DEFERRED,
"hours" integer NOT NULL,
UNIQUE ("event_id", "volunteer_id", "job_id")
);
```