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
0e1aaaa3
Commit
0e1aaaa3
authored
Apr 09, 2021
by
Aedin Hunter A. Clay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
can now edit questboard name, description, and required stars
parent
2c1b0b52
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
147 additions
and
10 deletions
+147
-10
forms.py
board/forms.py
+14
-2
0002_auto_20210409_1815.py
board/migrations/0002_auto_20210409_1815.py
+33
-0
models.py
board/models.py
+1
-1
urls.py
board/urls.py
+3
-0
views.py
board/views.py
+39
-3
base.html
templates/base.html
+1
-1
board.html
templates/board/board.html
+3
-1
edit_board.html
templates/board/edit_board.html
+53
-2
No files found.
board/forms.py
View file @
0e1aaaa3
...
@@ -9,8 +9,8 @@ class QuestboardForm(forms.ModelForm):
...
@@ -9,8 +9,8 @@ class QuestboardForm(forms.ModelForm):
class
QuestForm
(
forms
.
ModelForm
):
class
QuestForm
(
forms
.
ModelForm
):
class
Meta
:
class
Meta
:
model
=
Quest
model
=
Quest
fields
=
[
'board_
pk
'
,
'name'
,
'description'
,
'stars'
,
'for_everyone'
,
'student1'
,
'student2'
,
'student3'
]
fields
=
[
'board_
id
'
,
'name'
,
'description'
,
'stars'
,
'for_everyone'
,
'student1'
,
'student2'
,
'student3'
]
widgets
=
{
'board_
pk
'
:
forms
.
HiddenInput
(),
widgets
=
{
'board_
id
'
:
forms
.
HiddenInput
(),
'student1'
:
forms
.
HiddenInput
(),
'student1'
:
forms
.
HiddenInput
(),
'student2'
:
forms
.
HiddenInput
(),
'student2'
:
forms
.
HiddenInput
(),
'student3'
:
forms
.
HiddenInput
(),
'student3'
:
forms
.
HiddenInput
(),
...
@@ -19,3 +19,15 @@ class QuestForm(forms.ModelForm):
...
@@ -19,3 +19,15 @@ class QuestForm(forms.ModelForm):
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
)
class
EditBoardNameForm
(
forms
.
Form
):
board_id
=
forms
.
IntegerField
(
widget
=
forms
.
HiddenInput
())
name
=
forms
.
CharField
(
max_length
=
50
)
class
EditBoardDescForm
(
forms
.
Form
):
board_id
=
forms
.
IntegerField
(
widget
=
forms
.
HiddenInput
())
description
=
forms
.
CharField
(
max_length
=
300
)
class
EditBoardStarsForm
(
forms
.
Form
):
board_id
=
forms
.
IntegerField
(
widget
=
forms
.
HiddenInput
())
required_stars
=
forms
.
IntegerField
()
\ No newline at end of file
board/migrations/0002_auto_20210409_1815.py
0 → 100644
View file @
0e1aaaa3
# Generated by Django 3.1.7 on 2021-04-09 10:15
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'board'
,
'0001_initial'
),
]
operations
=
[
migrations
.
RenameField
(
model_name
=
'quest'
,
old_name
=
'board_pk'
,
new_name
=
'board_id'
,
),
migrations
.
AlterField
(
model_name
=
'quest'
,
name
=
'student1'
,
field
=
models
.
CharField
(
blank
=
True
,
default
=
''
,
max_length
=
60
),
),
migrations
.
AlterField
(
model_name
=
'quest'
,
name
=
'student2'
,
field
=
models
.
CharField
(
blank
=
True
,
default
=
''
,
max_length
=
60
),
),
migrations
.
AlterField
(
model_name
=
'quest'
,
name
=
'student3'
,
field
=
models
.
CharField
(
blank
=
True
,
default
=
''
,
max_length
=
60
),
),
]
board/models.py
View file @
0e1aaaa3
...
@@ -6,7 +6,7 @@ class Questboard(models.Model):
...
@@ -6,7 +6,7 @@ class Questboard(models.Model):
required_stars
=
models
.
IntegerField
()
required_stars
=
models
.
IntegerField
()
class
Quest
(
models
.
Model
):
class
Quest
(
models
.
Model
):
board_
pk
=
models
.
IntegerField
(
default
=
0
)
board_
id
=
models
.
IntegerField
(
default
=
0
)
name
=
models
.
CharField
(
max_length
=
60
,
default
=
''
)
name
=
models
.
CharField
(
max_length
=
60
,
default
=
''
)
description
=
models
.
CharField
(
max_length
=
300
,
default
=
''
)
description
=
models
.
CharField
(
max_length
=
300
,
default
=
''
)
stars
=
models
.
IntegerField
(
default
=
0
)
stars
=
models
.
IntegerField
(
default
=
0
)
...
...
board/urls.py
View file @
0e1aaaa3
...
@@ -4,6 +4,9 @@ from . import views
...
@@ -4,6 +4,9 @@ from . import views
urlpatterns
=
[
urlpatterns
=
[
path
(
'edit/<int:pk>'
,
views
.
edit_board_view
),
path
(
'edit/<int:pk>'
,
views
.
edit_board_view
),
path
(
'edit/edit_board_name/'
,
views
.
edit_board_name
),
path
(
'edit/edit_board_desc/'
,
views
.
edit_board_desc
),
path
(
'edit/edit_board_stars/'
,
views
.
edit_board_stars
),
path
(
'edit/add_quest/'
,
views
.
add_quest
),
path
(
'edit/add_quest/'
,
views
.
add_quest
),
path
(
'view/<int:pk>'
,
views
.
view_board_view
),
path
(
'view/<int:pk>'
,
views
.
view_board_view
),
path
(
'view/student_signup/'
,
views
.
student_signup
),
path
(
'view/student_signup/'
,
views
.
student_signup
),
...
...
board/views.py
View file @
0e1aaaa3
from
django.shortcuts
import
redirect
,
render
from
django.shortcuts
import
redirect
,
render
from
.models
import
Quest
,
Questboard
from
.models
import
Quest
,
Questboard
from
.forms
import
QuestForm
,
QuestboardForm
,
StudentSignupForm
from
.forms
import
*
def
edit_board_view
(
request
,
pk
):
def
edit_board_view
(
request
,
pk
):
...
@@ -9,8 +9,11 @@ def edit_board_view(request, pk):
...
@@ -9,8 +9,11 @@ def edit_board_view(request, pk):
'board/edit_board.html'
,
'board/edit_board.html'
,
{
{
'questboard'
:
Questboard
.
objects
.
get
(
pk
=
pk
),
'questboard'
:
Questboard
.
objects
.
get
(
pk
=
pk
),
'quests'
:
Quest
.
objects
.
filter
(
board_pk
=
pk
),
'quests'
:
Quest
.
objects
.
filter
(
board_id
=
pk
),
'add_quest_form'
:
QuestForm
(
initial
=
{
'board_pk'
:
pk
}),
'edit_board_name_form'
:
EditBoardNameForm
(
initial
=
{
'board_id'
:
pk
}),
'edit_board_desc_form'
:
EditBoardDescForm
(
initial
=
{
'board_id'
:
pk
}),
'edit_board_stars_form'
:
EditBoardStarsForm
(
initial
=
{
'board_id'
:
pk
}),
'add_quest_form'
:
QuestForm
(
initial
=
{
'board_id'
:
pk
}),
}
}
)
)
def
view_board_view
(
request
,
pk
):
def
view_board_view
(
request
,
pk
):
...
@@ -46,3 +49,36 @@ def student_signup(request):
...
@@ -46,3 +49,36 @@ def student_signup(request):
quest_to_edit
.
save
()
quest_to_edit
.
save
()
return
redirect
(
request
.
META
.
get
(
'HTTP_REFERER'
,
'/'
))
#PLEASE CHANGE THESE TO FUNCTION FOR CLARITY!!!
return
redirect
(
request
.
META
.
get
(
'HTTP_REFERER'
,
'/'
))
#PLEASE CHANGE THESE TO FUNCTION FOR CLARITY!!!
def
edit_board_name
(
request
):
if
request
.
method
==
"POST"
:
filled_form
=
EditBoardNameForm
(
request
.
POST
)
if
filled_form
.
is_valid
():
board_to_edit
=
Questboard
.
objects
.
get
(
pk
=
filled_form
.
cleaned_data
[
'board_id'
])
board_name
=
filled_form
.
cleaned_data
[
'name'
]
board_to_edit
.
name
=
board_name
board_to_edit
.
save
()
return
redirect
(
request
.
META
.
get
(
'HTTP_REFERER'
,
'/'
))
def
edit_board_desc
(
request
):
if
request
.
method
==
"POST"
:
filled_form
=
EditBoardDescForm
(
request
.
POST
)
if
filled_form
.
is_valid
():
board_to_edit
=
Questboard
.
objects
.
get
(
pk
=
filled_form
.
cleaned_data
[
'board_id'
])
board_desc
=
filled_form
.
cleaned_data
[
'description'
]
board_to_edit
.
description
=
board_desc
board_to_edit
.
save
()
return
redirect
(
request
.
META
.
get
(
'HTTP_REFERER'
,
'/'
))
def
edit_board_stars
(
request
):
if
request
.
method
==
"POST"
:
filled_form
=
EditBoardStarsForm
(
request
.
POST
)
if
filled_form
.
is_valid
():
board_to_edit
=
Questboard
.
objects
.
get
(
pk
=
filled_form
.
cleaned_data
[
'board_id'
])
board_stars
=
filled_form
.
cleaned_data
[
'required_stars'
]
board_to_edit
.
required_stars
=
board_stars
board_to_edit
.
save
()
return
redirect
(
request
.
META
.
get
(
'HTTP_REFERER'
,
'/'
))
\ No newline at end of file
templates/base.html
View file @
0e1aaaa3
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
</head>
</head>
<body>
<body>
<
p
class =
"website_header"
>
QUESTBOARD
</p
>
<
a
href =
"/home/"
><p
class =
"website_header"
>
QUESTBOARD
</p></a
>
<div
id=
"contents"
>
<div
id=
"contents"
>
<p
class =
"page_header"
>
{% block header %}{% endblock %}
</p>
<p
class =
"page_header"
>
{% block header %}{% endblock %}
</p>
...
...
templates/board/board.html
View file @
0e1aaaa3
...
@@ -14,6 +14,8 @@
...
@@ -14,6 +14,8 @@
Required Stars: {{questboard.required_stars}}
<br/>
Required Stars: {{questboard.required_stars}}
<br/>
{{questboard.description}}
<br/>
{{questboard.description}}
<br/>
{% block extra_content %}{% endblock %}
{% if quests %}
{% if quests %}
Quests in the Questboard:
Quests in the Questboard:
<div
id =
"quest_display"
>
<div
id =
"quest_display"
>
...
@@ -43,7 +45,7 @@ Required Stars: {{questboard.required_stars}}<br/>
...
@@ -43,7 +45,7 @@ Required Stars: {{questboard.required_stars}}<br/>
</div>
</div>
{% endif %}
{% endif %}
{% block extra_content %}{% endblock %}
{% block extra_scripts %}{% endblock %}
{% block extra_scripts %}{% endblock %}
{% endblock %}
{% endblock %}
...
...
templates/board/edit_board.html
View file @
0e1aaaa3
...
@@ -2,7 +2,37 @@
...
@@ -2,7 +2,37 @@
{% load static %}
{% load static %}
{% block extra_content %}
{% block extra_content %}
<button
onclick=
"showEditBoardName()"
>
Edit Questboard Name
</button>
<button
onclick=
"showEditBoardDesc()"
>
Edit Questboard Description
</button>
<button
onclick=
"showEditBoardStars()"
>
Edit Questboard Required Stars
</button>
<button
onclick=
"showAddQuest()"
>
Add Quest
</button>
<button
onclick=
"showAddQuest()"
>
Add Quest
</button>
<br/>
<dialog
id=
"edit_board_name"
>
<form
action =
"/questboard/edit/edit_board_name/"
method =
"post"
>
{% csrf_token %}
{{ edit_board_name_form }}
<button
type=
"submit"
>
Edit
</button>
</form>
<button
onclick =
"closeAllDialogBoxes()"
>
Cancel
</button>
</dialog>
<dialog
id=
"edit_board_desc"
>
<form
action =
"/questboard/edit/edit_board_desc/"
method =
"post"
>
{% csrf_token %}
{{ edit_board_desc_form }}
<button
type=
"submit"
>
Edit
</button>
</form>
<button
onclick =
"closeAllDialogBoxes()"
>
Cancel
</button>
</dialog>
<dialog
id=
"edit_board_stars"
>
<form
action =
"/questboard/edit/edit_board_stars/"
method =
"post"
>
{% csrf_token %}
{{ edit_board_stars_form }}
<button
type=
"submit"
>
Edit
</button>
</form>
<button
onclick =
"closeAllDialogBoxes()"
>
Cancel
</button>
</dialog>
<dialog
id=
"add_quest"
>
<dialog
id=
"add_quest"
>
<form
action =
"/questboard/edit/add_quest/"
method =
"post"
>
<form
action =
"/questboard/edit/add_quest/"
method =
"post"
>
...
@@ -16,12 +46,18 @@
...
@@ -16,12 +46,18 @@
{% block extra_scripts %}
{% block extra_scripts %}
<script>
<script>
AddQuest
=
document
.
getElementById
(
'add_quest'
);
AddQuest
=
document
.
getElementById
(
'add_quest'
);
EditBoardName
=
document
.
getElementById
(
'edit_board_name'
);
EditBoardDesc
=
document
.
getElementById
(
'edit_board_desc'
);
EditBoardStars
=
document
.
getElementById
(
'edit_board_stars'
);
function
closeAllDialogBoxes
(){
function
closeAllDialogBoxes
(){
AddQuest
.
close
();
AddQuest
.
close
();
EditBoardName
.
close
();
EditBoardDesc
.
close
();
EditBoardStars
.
close
();
}
}
function
showAddQuest
(){
function
showAddQuest
(){
...
@@ -29,6 +65,21 @@ function showAddQuest(){
...
@@ -29,6 +65,21 @@ function showAddQuest(){
AddQuest
.
show
();
AddQuest
.
show
();
}
}
</script>
function
showEditBoardName
(){
closeAllDialogBoxes
();
EditBoardName
.
show
();
}
function
showEditBoardDesc
(){
closeAllDialogBoxes
();
EditBoardDesc
.
show
();
}
function
showEditBoardStars
(){
closeAllDialogBoxes
();
EditBoardStars
.
show
();
}
</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