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
2c1b0b52
Commit
2c1b0b52
authored
Apr 09, 2021
by
Aedin Hunter A. Clay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
can now view questboard as student and sign up to a quest.
parent
58e77fd6
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
89 additions
and
8 deletions
+89
-8
forms.py
board/forms.py
+3
-2
urls.py
board/urls.py
+2
-0
views.py
board/views.py
+29
-2
views.py
homepage/views.py
+1
-1
board.html
templates/board/board.html
+2
-2
view_board.html
templates/board/view_board.html
+48
-0
homepage.html
templates/homepage/homepage.html
+4
-1
No files found.
board/forms.py
View file @
2c1b0b52
...
...
@@ -16,5 +16,6 @@ class QuestForm(forms.ModelForm):
'student3'
:
forms
.
HiddenInput
(),
}
class
AddStudentName
(
forms
.
Form
):
name
=
forms
.
CharField
(
max_length
=
60
)
\ No newline at end of file
class
StudentSignupForm
(
forms
.
Form
):
quest_id
=
forms
.
IntegerField
(
widget
=
forms
.
HiddenInput
())
name
=
forms
.
CharField
(
max_length
=
60
)
board/urls.py
View file @
2c1b0b52
...
...
@@ -5,4 +5,6 @@ from . import views
urlpatterns
=
[
path
(
'edit/<int:pk>'
,
views
.
edit_board_view
),
path
(
'edit/add_quest/'
,
views
.
add_quest
),
path
(
'view/<int:pk>'
,
views
.
view_board_view
),
path
(
'view/student_signup/'
,
views
.
student_signup
),
]
\ No newline at end of file
board/views.py
View file @
2c1b0b52
from
django.shortcuts
import
redirect
,
render
from
.models
import
Quest
,
Questboard
from
.forms
import
QuestForm
,
QuestboardForm
from
.forms
import
QuestForm
,
QuestboardForm
,
StudentSignupForm
def
edit_board_view
(
request
,
pk
):
return
render
(
...
...
@@ -12,10 +13,36 @@ def edit_board_view(request, pk):
'add_quest_form'
:
QuestForm
(
initial
=
{
'board_pk'
:
pk
}),
}
)
def
view_board_view
(
request
,
pk
):
return
render
(
request
,
'board/view_board.html'
,
{
'questboard'
:
Questboard
.
objects
.
get
(
pk
=
pk
),
'quests'
:
Quest
.
objects
.
filter
(
board_pk
=
pk
),
'signup_form'
:
StudentSignupForm
(
auto_id
=
'signup_
%
s'
)
}
)
def
add_quest
(
request
):
if
request
.
method
==
"POST"
:
filled_form
=
QuestForm
(
request
.
POST
)
if
filled_form
.
is_valid
():
filled_form
.
save
()
return
redirect
(
request
.
META
.
get
(
'HTTP_REFERER'
,
'/'
))
\ No newline at end of file
return
redirect
(
request
.
META
.
get
(
'HTTP_REFERER'
,
'/'
))
def
student_signup
(
request
):
if
request
.
method
==
"POST"
:
filled_form
=
StudentSignupForm
(
request
.
POST
)
if
filled_form
.
is_valid
():
quest_to_edit
=
Quest
.
objects
.
get
(
pk
=
filled_form
.
cleaned_data
[
'quest_id'
])
student_name
=
filled_form
.
cleaned_data
[
'name'
]
if
quest_to_edit
.
student1
==
''
:
quest_to_edit
.
student1
=
student_name
elif
quest_to_edit
.
student2
==
''
:
quest_to_edit
.
student2
=
student_name
elif
quest_to_edit
.
student3
==
''
:
quest_to_edit
.
student3
=
student_name
quest_to_edit
.
save
()
return
redirect
(
request
.
META
.
get
(
'HTTP_REFERER'
,
'/'
))
#PLEASE CHANGE THESE TO FUNCTION FOR CLARITY!!!
homepage/views.py
View file @
2c1b0b52
...
...
@@ -18,4 +18,4 @@ def add_questboard(request):
filled_form
=
QuestboardForm
(
request
.
POST
)
if
filled_form
.
is_valid
():
filled_form
.
save
()
return
redirect
(
request
.
META
.
get
(
'HTTP_REFERER'
,
'/'
))
\ No newline at end of file
return
redirect
(
request
.
META
.
get
(
'HTTP_REFERER'
,
'/'
))
\ No newline at end of file
templates/board/board.html
View file @
2c1b0b52
...
...
@@ -25,8 +25,6 @@ Required Stars: {{questboard.required_stars}}<br/>
<p
class =
"questbox_stars"
>
Stars : {{quest.stars}}
</p>
<div
class =
"questbox_students"
>
<!-- If the quest has three students -->
{% if quest.for_everyone is True %}
<b>
for everyone
</b>
{% else %}
...
...
@@ -50,3 +48,5 @@ Required Stars: {{questboard.required_stars}}<br/>
{% endblock %}
templates/board/view_board.html
0 → 100644
View file @
2c1b0b52
{% extends 'board/board.html' %}
{% load static %}
{% block questbox_actions %}
{% if quest.for_everyone is False %}
<!-- If the quest does not yet have three students -->
{% if quest.student1 == '' or quest.student2 == '' or quest.student3 == '' %}
<button
id=
"show_quest_signup"
onclick =
"showQuestSignup({{ quest.pk }})"
>
Sign Up for Quest
</button>
{% endif %}
{% endif %}
{% endblock %}
{% block extra_content %}
<dialog
id =
"quest_signup"
>
Please enter your name to sign up for this quest.
<form
action =
"/questboard/view/student_signup/"
method =
"post"
>
{% csrf_token %}
{{ signup_form }}
<button
type=
"submit"
>
Submit
</button>
</form>
<button
onclick =
"closeAllDialogBoxes()"
>
Cancel
</button>
</dialog>
{% endblock %}
{% block extra_scripts %}
<script>
QuestSignup
=
document
.
getElementById
(
'quest_signup'
);
function
closeAllDialogBoxes
(){
QuestSignup
.
close
();
}
function
showQuestSignup
(
pk
){
closeAllDialogBoxes
();
QuestSignup
.
show
();
selectQuestToSignupFor
(
pk
);
}
function
selectQuestToSignupFor
(
pk
){
document
.
getElementById
(
'signup_quest_id'
).
setAttribute
(
"value"
,
pk
)
}
</script>
{% endblock %}
\ No newline at end of file
templates/homepage/homepage.html
View file @
2c1b0b52
...
...
@@ -23,7 +23,10 @@
<td>
{{ board.name }}
</td>
<td>
<a
href =
"/questboard/edit/{{ board.pk }}"
>
<button
class =
"button"
>
Edit Questboard
</button>
<button
class =
"button"
>
Edit Questboard as Teacher
</button>
</a>
<a
href =
"/questboard/view/{{ board.pk }}"
>
<button
class =
"button"
>
View Questboard as Student
</button>
</a>
</td>
</tr>
...
...
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