Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
project_questboard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Aedin Hunter A. Clay
project_questboard
Commits
fbc9bda6
Commit
fbc9bda6
authored
Apr 10, 2021
by
Aedin Hunter A. Clay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleaned up code and added comments
parent
24351d19
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
101 additions
and
56 deletions
+101
-56
forms.py
board/forms.py
+2
-1
models.py
board/models.py
+2
-0
views.py
board/views.py
+11
-4
views.py
homepage/views.py
+5
-3
settings.py
project_questboard/settings.py
+1
-7
readme.txt
readme.txt
+6
-0
base.html
templates/base.html
+5
-3
board.html
templates/board/board.html
+25
-11
edit_board.html
templates/board/edit_board.html
+21
-8
view_board.html
templates/board/view_board.html
+14
-8
homepage.html
templates/homepage/homepage.html
+9
-11
No files found.
board/forms.py
View file @
fbc9bda6
...
@@ -21,7 +21,8 @@ class QuestForm(forms.ModelForm):
...
@@ -21,7 +21,8 @@ class QuestForm(forms.ModelForm):
'student2'
:
forms
.
HiddenInput
(),
'student2'
:
forms
.
HiddenInput
(),
'student3'
:
forms
.
HiddenInput
(),
'student3'
:
forms
.
HiddenInput
(),
}
}
#Form for signing up to quests
class
StudentSignupForm
(
forms
.
Form
):
class
StudentSignupForm
(
forms
.
Form
):
quest_id
=
forms
.
IntegerField
(
widget
=
forms
.
HiddenInput
())
quest_id
=
forms
.
IntegerField
(
widget
=
forms
.
HiddenInput
())
name
=
forms
.
CharField
(
max_length
=
60
)
name
=
forms
.
CharField
(
max_length
=
60
)
...
...
board/models.py
View file @
fbc9bda6
from
django.core.validators
import
MinValueValidator
from
django.core.validators
import
MinValueValidator
from
django.db
import
models
from
django.db
import
models
#Questboard: a place where Quests can be posted.
class
Questboard
(
models
.
Model
):
class
Questboard
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
50
)
name
=
models
.
CharField
(
max_length
=
50
)
description
=
models
.
CharField
(
max_length
=
300
)
description
=
models
.
CharField
(
max_length
=
300
)
required_stars
=
models
.
PositiveIntegerField
(
validators
=
[
MinValueValidator
(
0
)])
required_stars
=
models
.
PositiveIntegerField
(
validators
=
[
MinValueValidator
(
0
)])
#Quest: Students can sign up for quests. Each one is worth a certain number of stars.
class
Quest
(
models
.
Model
):
class
Quest
(
models
.
Model
):
board_id
=
models
.
PositiveIntegerField
(
default
=
0
,
validators
=
[
MinValueValidator
(
0
)])
board_id
=
models
.
PositiveIntegerField
(
default
=
0
,
validators
=
[
MinValueValidator
(
0
)])
name
=
models
.
CharField
(
max_length
=
60
,
default
=
''
)
name
=
models
.
CharField
(
max_length
=
60
,
default
=
''
)
...
...
board/views.py
View file @
fbc9bda6
...
@@ -3,7 +3,7 @@ from django.http import HttpRequest
...
@@ -3,7 +3,7 @@ from django.http import HttpRequest
from
.models
import
Quest
,
Questboard
from
.models
import
Quest
,
Questboard
from
.forms
import
*
from
.forms
import
*
#View that displays a questboard, allows it to be edited as a teacher
def
edit_board_view
(
request
,
pk
):
def
edit_board_view
(
request
,
pk
):
return
render
(
return
render
(
request
,
request
,
...
@@ -20,6 +20,8 @@ def edit_board_view(request, pk):
...
@@ -20,6 +20,8 @@ def edit_board_view(request, pk):
'delete_quest_form'
:
DeleteQuestForm
(
auto_id
=
'delete_
%
s'
),
'delete_quest_form'
:
DeleteQuestForm
(
auto_id
=
'delete_
%
s'
),
}
}
)
)
#View that displays a questboard, allows students to sign up for quests
def
view_board_view
(
request
,
pk
):
def
view_board_view
(
request
,
pk
):
return
render
(
return
render
(
request
,
request
,
...
@@ -31,9 +33,13 @@ def view_board_view(request, pk):
...
@@ -31,9 +33,13 @@ def view_board_view(request, pk):
'signup_form'
:
StudentSignupForm
(
auto_id
=
'signup_
%
s'
)
'signup_form'
:
StudentSignupForm
(
auto_id
=
'signup_
%
s'
)
}
}
)
)
#get the url of the questboard so it can be shared
def
get_share_url
(
request
,
pk
):
def
get_share_url
(
request
,
pk
):
return
request
.
build_absolute_uri
(
'/questboard/view/'
+
str
(
pk
))
return
request
.
build_absolute_uri
(
'/questboard/view/'
+
str
(
pk
))
#FUNCTIONS FOR MANIPULATING QUESTS
def
add_quest
(
request
):
def
add_quest
(
request
):
if
request
.
method
==
"POST"
:
if
request
.
method
==
"POST"
:
filled_form
=
QuestForm
(
request
.
POST
)
filled_form
=
QuestForm
(
request
.
POST
)
...
@@ -41,7 +47,8 @@ def add_quest(request):
...
@@ -41,7 +47,8 @@ def add_quest(request):
filled_form
.
save
()
filled_form
.
save
()
return
redirect
(
request
.
META
.
get
(
'HTTP_REFERER'
,
'/'
))
return
redirect
(
request
.
META
.
get
(
'HTTP_REFERER'
,
'/'
))
def
student_signup
(
request
):
# PLEASE ADD A "CHECK IF NAME IS THERE ALREADY" FUNCTION TO THE QUEST!
#signs students up to quests
def
student_signup
(
request
):
if
request
.
method
==
"POST"
:
if
request
.
method
==
"POST"
:
filled_form
=
StudentSignupForm
(
request
.
POST
)
filled_form
=
StudentSignupForm
(
request
.
POST
)
if
filled_form
.
is_valid
():
if
filled_form
.
is_valid
():
...
@@ -76,10 +83,11 @@ def delete_quest(request):
...
@@ -76,10 +83,11 @@ def delete_quest(request):
quest_to_delete
.
delete
()
quest_to_delete
.
delete
()
return
redirect
(
request
.
META
.
get
(
'HTTP_REFERER'
,
'/'
))
return
redirect
(
request
.
META
.
get
(
'HTTP_REFERER'
,
'/'
))
#FUNCTIONS FOR MANIPULATING QUESTBOARDS
def
edit_board_name
(
request
):
def
edit_board_name
(
request
):
if
request
.
method
==
"POST"
:
if
request
.
method
==
"POST"
:
filled_form
=
EditBoardNameForm
(
request
.
POST
)
filled_form
=
EditBoardNameForm
(
request
.
POST
)
if
filled_form
.
is_valid
():
if
filled_form
.
is_valid
():
board_to_edit
=
Questboard
.
objects
.
get
(
pk
=
filled_form
.
cleaned_data
[
'board_id'
])
board_to_edit
=
Questboard
.
objects
.
get
(
pk
=
filled_form
.
cleaned_data
[
'board_id'
])
board_name
=
filled_form
.
cleaned_data
[
'name'
]
board_name
=
filled_form
.
cleaned_data
[
'name'
]
...
@@ -90,7 +98,6 @@ def edit_board_name(request):
...
@@ -90,7 +98,6 @@ def edit_board_name(request):
def
edit_board_desc
(
request
):
def
edit_board_desc
(
request
):
if
request
.
method
==
"POST"
:
if
request
.
method
==
"POST"
:
filled_form
=
EditBoardDescForm
(
request
.
POST
)
filled_form
=
EditBoardDescForm
(
request
.
POST
)
if
filled_form
.
is_valid
():
if
filled_form
.
is_valid
():
board_to_edit
=
Questboard
.
objects
.
get
(
pk
=
filled_form
.
cleaned_data
[
'board_id'
])
board_to_edit
=
Questboard
.
objects
.
get
(
pk
=
filled_form
.
cleaned_data
[
'board_id'
])
board_desc
=
filled_form
.
cleaned_data
[
'description'
]
board_desc
=
filled_form
.
cleaned_data
[
'description'
]
...
...
homepage/views.py
View file @
fbc9bda6
from
django.shortcuts
import
redirect
,
render
from
django.shortcuts
import
redirect
,
render
from
board.models
import
Questboard
from
board.forms
import
QuestboardForm
from
board.forms
import
QuestboardForm
from
board.models
import
Questboard
def
redirect_to_home
(
request
):
def
redirect_to_home
(
request
):
return
redirect
(
'/home/'
)
return
redirect
(
'/home/'
)
...
@@ -12,10 +12,12 @@ def homepage_view(request):
...
@@ -12,10 +12,12 @@ def homepage_view(request):
'boards'
:
Questboard
.
objects
.
all
(),
'boards'
:
Questboard
.
objects
.
all
(),
'add_board_form'
:
QuestboardForm
(),
'add_board_form'
:
QuestboardForm
(),
})
})
def
add_questboard
(
request
):
def
add_questboard
(
request
):
if
request
.
method
==
"POST"
:
if
request
.
method
==
"POST"
:
filled_form
=
QuestboardForm
(
request
.
POST
)
filled_form
=
QuestboardForm
(
request
.
POST
)
if
filled_form
.
is_valid
():
if
filled_form
.
is_valid
():
new_questboard
=
filled_form
.
save
()
new_questboard
=
filled_form
.
save
()
return
redirect
(
'/questboard/edit/'
+
str
(
new_questboard
.
id
))
#redirect to the newly created questboard
\ No newline at end of file
return
redirect
(
'/questboard/edit/'
+
str
(
new_questboard
.
id
))
return
redirect_to_home
(
request
)
\ No newline at end of file
project_questboard/settings.py
View file @
fbc9bda6
...
@@ -9,7 +9,6 @@ BASE_DIR = Path(__file__).resolve().parent.parent
...
@@ -9,7 +9,6 @@ BASE_DIR = Path(__file__).resolve().parent.parent
load_dotenv
()
load_dotenv
()
# Quick-start development settings - unsuitable for production
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY
=
'#(49vncg1=2+(7=73as12d0*_h52w6$2
%-
sjqmtj@580mr+(-k'
SECRET_KEY
=
'#(49vncg1=2+(7=73as12d0*_h52w6$2
%-
sjqmtj@580mr+(-k'
...
@@ -19,7 +18,6 @@ DEBUG = True
...
@@ -19,7 +18,6 @@ DEBUG = True
ALLOWED_HOSTS
=
[]
ALLOWED_HOSTS
=
[]
# Application definition
# Application definition
INSTALLED_APPS
=
[
INSTALLED_APPS
=
[
...
@@ -65,8 +63,7 @@ TEMPLATES = [
...
@@ -65,8 +63,7 @@ TEMPLATES = [
WSGI_APPLICATION
=
'project_questboard.wsgi.application'
WSGI_APPLICATION
=
'project_questboard.wsgi.application'
# Database
# Postgres Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
DATABASES
=
{
DATABASES
=
{
'default'
:
{
'default'
:
{
...
@@ -81,7 +78,6 @@ DATABASES = {
...
@@ -81,7 +78,6 @@ DATABASES = {
# Password validation
# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS
=
[
AUTH_PASSWORD_VALIDATORS
=
[
{
{
...
@@ -100,7 +96,6 @@ AUTH_PASSWORD_VALIDATORS = [
...
@@ -100,7 +96,6 @@ AUTH_PASSWORD_VALIDATORS = [
# Internationalization
# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/
LANGUAGE_CODE
=
'en-us'
LANGUAGE_CODE
=
'en-us'
...
@@ -114,7 +109,6 @@ USE_TZ = True
...
@@ -114,7 +109,6 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images)
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/
STATIC_URL
=
'/static/'
STATIC_URL
=
'/static/'
STATICFILES_DIRS
=
[
os
.
path
.
join
(
BASE_DIR
,
'static'
)]
STATICFILES_DIRS
=
[
os
.
path
.
join
(
BASE_DIR
,
'static'
)]
readme.txt
0 → 100644
View file @
fbc9bda6
For the postgres database:
Please create a .env with the following variables:
DB_NAME : name of the database to use
DB_USER : username of postgres account
DB_PASS : password of postgres account
templates/base.html
View file @
fbc9bda6
<!--Template for basic web page in Questboard.-->
<!--Template for basic web page in Questboard.-->
{% load static %}
{% load static %}
<html>
<html>
<head>
<head>
<title>
{% block title %}{% endblock %}
</title>
<title>
{% block title %}{% endblock %}
</title>
...
@@ -21,13 +18,18 @@
...
@@ -21,13 +18,18 @@
<body>
<body>
<a
href =
"/home/"
><p
class =
"homepage_link"
>
Back to Homepage
</p></a>
<a
href =
"/home/"
><p
class =
"homepage_link"
>
Back to Homepage
</p></a>
<div
id=
"contents"
>
<div
id=
"contents"
>
<a
href =
"/home/"
><p
class =
"website_header"
>
Questboard!
</p></a>
<a
href =
"/home/"
><p
class =
"website_header"
>
Questboard!
</p></a>
<p
class =
"website_author"
>
Implemented by Aedin Clay
</p>
<p
class =
"website_author"
>
Implemented by Aedin Clay
</p>
<!-- Page title and contents go here -->
<p
class =
"page_header"
>
{% block header %}{% endblock %}
</p>
<p
class =
"page_header"
>
{% block header %}{% endblock %}
</p>
{% block content %}{% endblock %}
{% block content %}{% endblock %}
</div>
</div>
<!-- Additional Scripts -->
{% block scripts %}{% endblock %}
{% block scripts %}{% endblock %}
</body>
</body>
...
...
templates/board/board.html
View file @
fbc9bda6
<!-- BASIC TEMPLATE FOR DISPLAYING THE CONTENTS OF A QUESTBOARD-->
<!-- Includes questboard name, description, required stars, and url. -->
<!-- Also includes details of all quests in the questboard -->
{% extends 'base.html' %}
{% extends 'base.html' %}
{% load static %}
{% load static %}
<!-- BASIC PAGE INFORMATION -->
{% block title%}{{questboard.name}}{% endblock %}
{% block title%}{{questboard.name}}{% endblock %}
{% block styles %}
{% block styles %}
<link
rel =
"stylesheet"
href =
"{% static 'board/board.css' %}"
>
<link
rel =
"stylesheet"
href =
"{% static 'board/board.css' %}"
>
{% endblock %}
{% endblock %}
{% block header %}{{questboard.name}}{% endblock %}
{% block header %}{{questboard.name}}{% endblock %}
<!-- PAGE CONTENTS -->
{% block content %}
{% block content %}
<!-- Questboard name and description -->
<div
class =
"infobox"
>
<div
class =
"infobox"
>
<p><b>
Description:
</b>
{{questboard.description}}
</p>
<p><b>
Description:
</b>
{{questboard.description}}
</p>
<p><b>
Required stars:
</b>
{{questboard.required_stars}}
</p>
<p><b>
Required stars:
</b>
{{questboard.required_stars}}
</p>
</div>
</div>
<!--
Copy questboard link
-->
<!--
Button to copy questboard url
-->
<button
onclick =
"copyQuestboardLink()"
class =
"button"
>
Copy Questboard Link
</button>
<button
onclick =
"copyQuestboardLink()"
class =
"button"
>
Copy Questboard Link
</button>
<script>
<script>
function
copyQuestboardLink
(){
function
copyQuestboardLink
(){
var
link_area
=
document
.
createElement
(
"textarea"
)
var
link_area
=
document
.
createElement
(
"textarea"
)
...
@@ -30,18 +34,26 @@ function copyQuestboardLink(){
...
@@ -30,18 +34,26 @@ function copyQuestboardLink(){
}
}
</script>
</script>
{% block extra_content %}{% endblock %}
<!-- Extra menu options for viewing and editing questboard -->
<br/>
{% block extra_content %}{% endblock %}
<br/>
<!-- Display area for Quests-->
<p
class =
"sub_header"
>
Quests:
</p>
<p
class =
"sub_header"
>
Quests:
</p>
{% if quests %}
{% if quests %}
<div
id =
"quest_display"
>
<div
id =
"quest_display"
>
{% for quest in quests %}
{% for quest in quests %}
<!-- Display box for Single Quest -->
<div
class =
"questbox_wrapper"
>
<div
class =
"questbox_wrapper"
>
<div
class =
"questbox"
>
<div
class =
"questbox"
>
<!-- Quest information -->
<p
class =
"questbox_name"
>
{{ quest.name }}
</p>
<p
class =
"questbox_name"
>
{{ quest.name }}
</p>
<p
class =
"questbox_description"
>
{{ quest.description }}
</p>
<p
class =
"questbox_description"
>
{{ quest.description }}
</p>
<p
class =
"questbox_stars"
>
Stars : {{quest.stars}}
</p>
<p
class =
"questbox_stars"
>
Stars : {{quest.stars}}
</p>
<!-- List of Students to sign up to the quest -->
<div
class =
"questbox_students"
>
<div
class =
"questbox_students"
>
{% if quest.for_everyone is True %}
{% if quest.for_everyone is True %}
This Quest is for everyone.
This Quest is for everyone.
...
@@ -53,21 +65,23 @@ function copyQuestboardLink(){
...
@@ -53,21 +65,23 @@ function copyQuestboardLink(){
</ol>
</ol>
{% endif %}
{% endif %}
</div>
</div>
<!-- Actions for the Quest (edit, delete, sign up)-->
<span
class =
"questbox_actions"
>
<span
class =
"questbox_actions"
>
{% block questbox_actions %}{% endblock %}
{% block questbox_actions %}{% endblock %}
</span>
</span>
</div>
</div>
</div>
</div>
{% endfor %}
{% endfor %}
</div>
</div>
<!-- If there are no quests in the questboard, display this message-->
{% else %}
{% else %}
<i>
No Quests so Far
</i>
<i>
No Quests so Far
</i>
{% endif %}
{% endif %}
<!-- Additional Scripts-->
{% block extra_scripts %}{% endblock %}
{% block extra_scripts %}{% endblock %}
{% endblock %}
{% endblock %}
\ No newline at end of file
templates/board/edit_board.html
View file @
fbc9bda6
<!-- PAGE FOR EDITING QUESTBOARD AND QUESTS AS A TEACHER-->
{% extends 'board/board.html' %}
{% extends 'board/board.html' %}
{% load static %}
{% load static %}
{% block extra_content %}
{% block extra_content %}
<!-- Dropdown box for Editing Questboard-->
<div
class =
"dropdown"
>
<div
class =
"dropdown"
>
<button
class =
"button"
>
Edit Options
</button>
<button
class =
"button"
>
Edit Options
</button>
<div
class =
"dropdown-content"
>
<div
class =
"dropdown-content"
>
...
@@ -12,6 +15,7 @@
...
@@ -12,6 +15,7 @@
</div>
</div>
<button
class =
"button"
onclick=
"showAddQuest()"
>
Add Quest
</button>
<button
class =
"button"
onclick=
"showAddQuest()"
>
Add Quest
</button>
<!-- Dialog box for Editing Questboard Name-->
<br/>
<br/>
<dialog
id=
"edit_board_name"
>
<dialog
id=
"edit_board_name"
>
<form
action =
"/questboard/edit/edit_board_name/"
method =
"post"
>
<form
action =
"/questboard/edit/edit_board_name/"
method =
"post"
>
...
@@ -22,6 +26,7 @@
...
@@ -22,6 +26,7 @@
<button
onclick =
"closeAllDialogBoxes()"
>
Cancel
</button>
<button
onclick =
"closeAllDialogBoxes()"
>
Cancel
</button>
</dialog>
</dialog>
<!-- Dialog box for Editing Questboard Description-->
<dialog
id=
"edit_board_desc"
>
<dialog
id=
"edit_board_desc"
>
<form
action =
"/questboard/edit/edit_board_desc/"
method =
"post"
>
<form
action =
"/questboard/edit/edit_board_desc/"
method =
"post"
>
{% csrf_token %}
{% csrf_token %}
...
@@ -31,6 +36,7 @@
...
@@ -31,6 +36,7 @@
<button
onclick =
"closeAllDialogBoxes()"
>
Cancel
</button>
<button
onclick =
"closeAllDialogBoxes()"
>
Cancel
</button>
</dialog>
</dialog>
<!-- Dialog box for Editing Questboard Required Stars-->
<dialog
id=
"edit_board_stars"
>
<dialog
id=
"edit_board_stars"
>
<form
action =
"/questboard/edit/edit_board_stars/"
method =
"post"
>
<form
action =
"/questboard/edit/edit_board_stars/"
method =
"post"
>
{% csrf_token %}
{% csrf_token %}
...
@@ -40,6 +46,7 @@
...
@@ -40,6 +46,7 @@
<button
onclick =
"closeAllDialogBoxes()"
>
Cancel
</button>
<button
onclick =
"closeAllDialogBoxes()"
>
Cancel
</button>
</dialog>
</dialog>
<!-- Dialog box for Adding Quests-->
<dialog
id=
"add_quest"
>
<dialog
id=
"add_quest"
>
<form
action =
"/questboard/edit/add_quest/"
method =
"post"
>
<form
action =
"/questboard/edit/add_quest/"
method =
"post"
>
{% csrf_token %}
{% csrf_token %}
...
@@ -49,6 +56,7 @@
...
@@ -49,6 +56,7 @@
<button
onclick =
"closeAllDialogBoxes()"
>
Cancel
</button>
<button
onclick =
"closeAllDialogBoxes()"
>
Cancel
</button>
</dialog>
</dialog>
<!-- Dialog box for Editing Quests-->
<dialog
id=
"edit_quest"
>
<dialog
id=
"edit_quest"
>
<form
action =
"/questboard/edit/edit_quest/"
method =
"post"
>
<form
action =
"/questboard/edit/edit_quest/"
method =
"post"
>
{% csrf_token %}
{% csrf_token %}
...
@@ -58,6 +66,7 @@
...
@@ -58,6 +66,7 @@
<button
onclick =
"closeAllDialogBoxes()"
>
Cancel
</button>
<button
onclick =
"closeAllDialogBoxes()"
>
Cancel
</button>
</dialog>
</dialog>
<!-- Dialog box for Deleting Quests-->
<dialog
id=
"delete_quest"
>
<dialog
id=
"delete_quest"
>
Are you sure you want to delete this quest?
Are you sure you want to delete this quest?
<form
action =
"/questboard/edit/delete_quest/"
method =
"post"
>
<form
action =
"/questboard/edit/delete_quest/"
method =
"post"
>
...
@@ -69,19 +78,22 @@
...
@@ -69,19 +78,22 @@
</dialog>
</dialog>
{% endblock %}
{% endblock %}
<!-- Buttons and options for manipulating individual Quests -->
{% block questbox_actions %}
{% block questbox_actions %}
<!-- If no student has signed up yet or the quest is for everyone, then the quest can be edited / deleted -->
<!-- If no student has signed up yet or the quest is for everyone, then the quest can be edited / deleted -->
{% if quest.student1 == '' and quest.student2 == '' and quest.student3 == '' %}
{% if quest.student1 == '' and quest.student2 == '' and quest.student3 == '' %}
<button
onclick=
"showEditQuest({{quest.pk}})"
class =
"button"
>
Edit Quest
</button>
<button
onclick=
"showEditQuest({{quest.pk}})"
class =
"button"
>
Edit Quest
</button>
<button
onclick=
"showDeleteQuest({{quest.pk}})"
class =
"button"
>
Delete Quest
</button>
<button
onclick=
"showDeleteQuest({{quest.pk}})"
class =
"button"
>
Delete Quest
</button>
{% else %}
{% else %}
<p>
Cannot Edit Quest: students have already signed up.
</p>
<p>
Cannot Edit Quest: students have already signed up.
</p>
{% endif %}
{% endif %}
{% endblock %}
{% endblock %}
<!-- Additional Scripts -->
{% block extra_scripts %}
{% block extra_scripts %}
<script>
<script>
// Store Dialog Boxes as Variables
AddQuest
=
document
.
getElementById
(
'add_quest'
);
AddQuest
=
document
.
getElementById
(
'add_quest'
);
EditQuest
=
document
.
getElementById
(
'edit_quest'
);
EditQuest
=
document
.
getElementById
(
'edit_quest'
);
DeleteQuest
=
document
.
getElementById
(
'delete_quest'
);
DeleteQuest
=
document
.
getElementById
(
'delete_quest'
);
...
@@ -98,6 +110,7 @@ function closeAllDialogBoxes(){
...
@@ -98,6 +110,7 @@ function closeAllDialogBoxes(){
EditBoardStars
.
close
();
EditBoardStars
.
close
();
}
}
// Store value of quest being edited or deleted to Form being sent
function
selectQuestToEdit
(
pk
){
function
selectQuestToEdit
(
pk
){
document
.
getElementById
(
'edit_quest_id'
).
setAttribute
(
"value"
,
pk
)
document
.
getElementById
(
'edit_quest_id'
).
setAttribute
(
"value"
,
pk
)
}
}
...
@@ -106,6 +119,7 @@ function selectQuestToDelete(pk){
...
@@ -106,6 +119,7 @@ function selectQuestToDelete(pk){
document
.
getElementById
(
'delete_quest_id'
).
setAttribute
(
"value"
,
pk
)
document
.
getElementById
(
'delete_quest_id'
).
setAttribute
(
"value"
,
pk
)
}
}
//Functions for displaying Dialog Boxes
function
showAddQuest
(){
function
showAddQuest
(){
closeAllDialogBoxes
();
closeAllDialogBoxes
();
AddQuest
.
show
();
AddQuest
.
show
();
...
@@ -137,6 +151,5 @@ function showDeleteQuest(pk){
...
@@ -137,6 +151,5 @@ function showDeleteQuest(pk){
DeleteQuest
.
show
();
DeleteQuest
.
show
();
selectQuestToDelete
(
pk
);
selectQuestToDelete
(
pk
);
}
}
</script>
</script>
{% endblock %}
{% endblock %}
\ No newline at end of file
templates/board/view_board.html
View file @
fbc9bda6
<!-- Page to View Questboard as Student-->
{% extends 'board/board.html' %}
{% extends 'board/board.html' %}
{% load static %}
{% load static %}
<!-- Button for Signing up to Quest -->
{% block questbox_actions %}
{% block questbox_actions %}
<!-- If the quest is not for everyone and if the quest does not yet have three students, show Signup button -->
{% if quest.for_everyone is False %}
{% if quest.for_everyone is False %}
<!-- If the quest does not yet have three students -->
{% if quest.student1 == '' or quest.student2 == '' or quest.student3 == '' %}
{% if quest.student1 == '' or quest.student2 == '' or quest.student3 == '' %}
<button
id=
"show_quest_signup"
onclick =
"showQuestSignup({{ quest.pk }})"
>
Sign Up for Quest
</button>
<button
id=
"show_quest_signup"
onclick =
"showQuestSignup({{ quest.pk }})"
>
Sign Up for Quest
</button>
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endblock %}
{% endblock %}
{% block extra_content %}
{% block extra_content %}
<!-- Dialog box for signing up to quests-->
<dialog
id =
"quest_signup"
>
<dialog
id =
"quest_signup"
>
Please enter your name to sign up for this quest.
Please enter your name to sign up for this quest.
<form
action =
"/questboard/view/student_signup/"
method =
"post"
>
<form
action =
"/questboard/view/student_signup/"
method =
"post"
>
...
@@ -24,6 +26,7 @@
...
@@ -24,6 +26,7 @@
</dialog>
</dialog>
{% endblock %}
{% endblock %}
<!-- Additional Scripts-->
{% block extra_scripts %}
{% block extra_scripts %}
<script>
<script>
...
@@ -33,15 +36,18 @@ function closeAllDialogBoxes(){
...
@@ -33,15 +36,18 @@ function closeAllDialogBoxes(){
QuestSignup
.
close
();
QuestSignup
.
close
();
}
}
// Store value of quest to sign up for into Form being sent
function
selectQuestToSignupFor
(
pk
){
document
.
getElementById
(
'signup_quest_id'
).
setAttribute
(
"value"
,
pk
)
}
function
showQuestSignup
(
pk
){
function
showQuestSignup
(
pk
){
closeAllDialogBoxes
();
closeAllDialogBoxes
();
QuestSignup
.
show
();
QuestSignup
.
show
();
selectQuestToSignupFor
(
pk
);
selectQuestToSignupFor
(
pk
);
}
}
function
selectQuestToSignupFor
(
pk
){
document
.
getElementById
(
'signup_quest_id'
).
setAttribute
(
"value"
,
pk
)
}
...
...
templates/homepage/homepage.html
View file @
fbc9bda6
<!-- HOMEPAGE.HTML -->
{% extends 'base.html' %}
{% extends 'base.html' %}
{% load static %}
{% load static %}
<!-- BASIC PAGE INFORMATION-->
{% block title%}Homepage{% endblock %}
{% block title%}Homepage{% endblock %}
{% block styles %}
<link
rel =
"stylesheet"
href =
"{% static 'homepage/homepage.css' %}"
>
{% endblock %}
{% block header %}Homepage{% endblock %}
{% block header %}Homepage{% endblock %}
<!-- PAGE CONTENTS -->
{% block content %}
{% block content %}
<!--
LIST
OF QUESTBOARDS -->
<!--
TABLE
OF QUESTBOARDS -->
<table
class =
"board_table"
>
<table
class =
"board_table"
>
<tr>
<tr>
<th>
Questboard Name
</th>
<th>
Questboard Name
</th>
<th>
Actions
</th>
<th>
Actions
</th>
</tr>
</tr>
<!-- Displays one questboard per table row -->
{% for board in boards %}
{% for board in boards %}
<tr>
<tr>
<td>
{{ board.name }}
</td>
<td>
{{ board.name }}
</td>
...
@@ -31,13 +30,12 @@
...
@@ -31,13 +30,12 @@
</td>
</td>
</tr>
</tr>
{% endfor %}
{% endfor %}
</table>
</table>
<button
class =
"button"
onclick =
"showAddBoard()"
>
Add a Questboard
</button>
<button
class =
"button"
onclick =
"showAddBoard()"
>
Add a Questboard
</button>
<!-- DIALOG BOX FOR ADDING A QUESTBOARD-->
<dialog
id=
"add_board"
>
<!-- PLEASE PREVENT NEGATIVE NUMBERS!!!-->
<dialog
id=
"add_board"
>
<form
action =
"add_board/"
method =
"post"
>
<form
action =
"add_board/"
method =
"post"
>
{% csrf_token %}
{% csrf_token %}
{{ add_board_form }}
{{ add_board_form }}
...
@@ -45,9 +43,10 @@
...
@@ -45,9 +43,10 @@
</form>
</form>
<button
onclick =
"closeAllDialogBoxes()"
>
Cancel
</button>
<button
onclick =
"closeAllDialogBoxes()"
>
Cancel
</button>
</dialog>
</dialog>
{% endblock %}
{% endblock %}
<!-- PAGE SCRIPTS -->
{% block scripts %}
{% block scripts %}
<script>
<script>
AddBoard
=
document
.
getElementById
(
"add_board"
);
AddBoard
=
document
.
getElementById
(
"add_board"
);
...
@@ -60,6 +59,5 @@ function showAddBoard(){
...
@@ -60,6 +59,5 @@ function showAddBoard(){
closeAllDialogBoxes
();
closeAllDialogBoxes
();
AddBoard
.
show
();
AddBoard
.
show
();
}
}
</script>
</script>
{% endblock %}
{% endblock %}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment