-
Notifications
You must be signed in to change notification settings - Fork 9
/
Overview.txt
73 lines (47 loc) · 3.09 KB
/
Overview.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
## 1. Structure of OPRA:
compsocsite/
1. manage.py
// Use this file to run this project
2. appauth
// This folder is for registering users and login/logout. Also includes global settings.
3. compsocsite
// This is the global folder for OPRA.
4. polls
// For single polls. This is the core of the project.
5. multipolls
// For multi-polls. Polling can be done in multiple rounds. Code is built off of polls.
6. groups
// For groups. Groups are used to making adding and removing a large number of voters convenient
7. static
// For image, js, css files
## 2. Structure of each folder
Generally, each main app folder (polls, multipolls, groups) will follow a similar structure.
migrations (folder): Used to store database changes as the model is updated. The files are updated automatically using the commands:
<code> python3 manage.py makemigrations </code>
<code> python3 manage.py migrate </code>
templates (folder): This contains all the view files, which are a mix of HTML and Django template language. You can customize the display of each file in your browser.
models.py: Contains all the model (class) definitions.
urls.py: Contains a list of links displayed in the browser, where each link has its own function. The function can either render the view or perform calculations.
views.py: Contains all the logic required to retrieve data from the database and perform calculations.
Keep in mind:
Every time you add a new model, you update models.py and then migrate the database.
Every time you want to add a new template page, you add a new file to the templates folder and then update urls.py and views.py so that Django will know how to render the page.
## 3. Detailed structure of each app
1. appauth:
Models:
User: Borrowed from Django implementation of User. It stores a user's username, password, email address, etc. For more information on Django implementation of User model, please go to corresponding Django documentation page.
UserProfile: This model is implemented to record global settings for a single user to avoid modifying Django's User model. It is in an one-to-one relationship to User model.
Functions:
register: This functions runs when a registration form is submitted. A user instance and a userprofile instance are created if username is valid.
user_login: A function for checking the authenticity of a user's request and processes login information.
displaySettings, globalSettings, updateSettings, disableHint, changePassword: These functions are used in global setting and account setting pages.
2. groups:
Models:
Group: A group model that links several users together into a group for user's convenience in inviting voters.
Functions:
IndexView, AddGroupView, MembersView: Pages for group settings and adding groups.
addgroup, addmember, removemember, deletegroup: Functions used for group settings.
addGroupVoters, removeGroupVoters: Used at group voter invitations.
3. polls:
Models:
Question: Also known as poll. Aside from basic data such as title and description, it stores a number of relationship fields as well.