This repository has been archived by the owner on May 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 178
/
forms.py
89 lines (70 loc) · 2.41 KB
/
forms.py
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# _ _ __ __
# __| |(_)__ _ _ _ __ _ ___ _ \ \ / /
# / _` || / _` | ' \/ _` / _ \_| ' \ V /
# \__,_|/ \__,_|_||_\__, \___(_)_||_\_/
# |__/ |___/
#
# INSECURE APPLICATION WARNING
#
# django.nV is a PURPOSELY INSECURE web-application
# meant to demonstrate Django security problems
# UNDER NO CIRCUMSTANCES should you take any code
# from django.nV for use in another web application!
#
""" forms.py contains various Django forms for the application """
from taskManager.models import Project, Task
from django import forms
from django.contrib.auth.models import User
def get_my_choices_users():
""" Retrieves a list of all users in the system
for the user management page
"""
user_list = User.objects.order_by('date_joined')
user_tuple = []
counter = 1
for user in user_list:
user_tuple.append((counter, user))
counter = counter + 1
return user_tuple
def get_my_choices_tasks(current_proj):
""" Retrieves all tasks in the system
for the task management page
"""
task_list = []
tasks = Task.objects.all()
for task in tasks:
if task.project == current_proj:
task_list.append(task)
task_tuple = []
counter = 1
for task in task_list:
task_tuple.append((counter, task))
counter = counter + 1
return task_tuple
def get_my_choices_projects():
""" Retrieves all projects in the system
for the project management page
"""
proj_list = Project.objects.all()
proj_tuple = []
counter = 1
for proj in proj_list:
proj_tuple.append((counter, proj))
counter = counter + 1
return proj_tuple
# A2: Broken Authentication and Session Management
class UserForm(forms.ModelForm):
""" User registration form """
class Meta:
model = User
exclude = ['groups', 'user_permissions', 'last_login', 'date_joined', 'is_active']
class ProjectFileForm(forms.Form):
""" Used for uploading files attached to projects """
name = forms.CharField(max_length=300)
file = forms.FileField()
class ProfileForm(forms.Form):
""" Provides a form for editing your own profile """
first_name = forms.CharField(max_length=30, required=False)
last_name = forms.CharField(max_length=30, required=False)
email = forms.CharField(max_length=300, required=False)
picture = forms.FileField(required=False)