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
22d2d95d
Commit
22d2d95d
authored
Apr 09, 2021
by
Aedin Hunter A. Clay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
can now view the edit questboard page, and add quests to questboard
parent
0de6c440
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
64 additions
and
32 deletions
+64
-32
forms.py
board/forms.py
+3
-2
models.py
board/models.py
+3
-3
urls.py
board/urls.py
+3
-1
views.py
board/views.py
+19
-1
views.py
homepage/views.py
+2
-5
urls.py
project_questboard/urls.py
+1
-1
edit_board.html
templates/board/edit_board.html
+14
-12
homepage.html
templates/homepage/homepage.html
+19
-7
No files found.
board/forms.py
View file @
22d2d95d
...
@@ -9,8 +9,9 @@ class QuestboardForm(forms.ModelForm):
...
@@ -9,8 +9,9 @@ class QuestboardForm(forms.ModelForm):
class
QuestForm
(
forms
.
ModelForm
):
class
QuestForm
(
forms
.
ModelForm
):
class
Meta
:
class
Meta
:
model
=
Quest
model
=
Quest
fields
=
[
'
name'
,
'description'
,
'stars'
,
'for_everyone'
,
'board_pk'
,
'student1'
,
'student2'
,
'student3'
]
fields
=
[
'
board_pk'
,
'name'
,
'description'
,
'stars'
,
'for_everyone'
,
'student1'
,
'student2'
,
'student3'
]
widgets
=
{
'board_pk'
:
forms
.
HiddenInput
(),
widgets
=
{
'board_pk'
:
forms
.
HiddenInput
(),
'student1'
:
forms
.
HiddenInput
(),
'student1'
:
forms
.
HiddenInput
(),
'student2'
:
forms
.
HiddenInput
(),
'student2'
:
forms
.
HiddenInput
(),
'student3'
:
forms
.
HiddenInput
()}
'student3'
:
forms
.
HiddenInput
(),
\ No newline at end of file
}
\ No newline at end of file
board/models.py
View file @
22d2d95d
...
@@ -11,9 +11,9 @@ class Quest(models.Model):
...
@@ -11,9 +11,9 @@ class Quest(models.Model):
description
=
models
.
CharField
(
max_length
=
300
,
default
=
''
)
description
=
models
.
CharField
(
max_length
=
300
,
default
=
''
)
stars
=
models
.
IntegerField
(
default
=
0
)
stars
=
models
.
IntegerField
(
default
=
0
)
for_everyone
=
models
.
BooleanField
(
default
=
False
)
for_everyone
=
models
.
BooleanField
(
default
=
False
)
student1
=
models
.
CharField
(
max_length
=
60
,
default
=
''
)
student1
=
models
.
CharField
(
max_length
=
60
,
default
=
''
,
blank
=
True
)
student2
=
models
.
CharField
(
max_length
=
60
,
default
=
''
)
student2
=
models
.
CharField
(
max_length
=
60
,
default
=
''
,
blank
=
True
)
student3
=
models
.
CharField
(
max_length
=
60
,
default
=
''
)
student3
=
models
.
CharField
(
max_length
=
60
,
default
=
''
,
blank
=
True
)
def
is_for_everyone
(
self
):
def
is_for_everyone
(
self
):
if
self
.
students
is
not
None
:
if
self
.
students
is
not
None
:
...
...
board/urls.py
View file @
22d2d95d
...
@@ -3,4 +3,6 @@ from django.urls import path
...
@@ -3,4 +3,6 @@ from django.urls import path
from
.
import
views
from
.
import
views
urlpatterns
=
[
urlpatterns
=
[
]
path
(
'edit/<int:pk>'
,
views
.
edit_board_view
),
path
(
'edit/add_quest/'
,
views
.
add_quest
),
]
\ No newline at end of file
board/views.py
View file @
22d2d95d
from
django.shortcuts
import
render
from
django.shortcuts
import
redirect
,
render
from
.models
import
Quest
,
Questboard
from
.forms
import
QuestForm
,
QuestboardForm
def
edit_board_view
(
request
,
pk
):
return
render
(
request
,
'board/edit_board.html'
,
{
'questboard'
:
Questboard
.
objects
.
get
(
pk
=
pk
),
'quests'
:
Quest
.
objects
.
filter
(
board_pk
=
pk
),
'add_quest_form'
:
QuestForm
(
initial
=
{
'board_pk'
:
pk
}),
}
)
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
homepage/views.py
View file @
22d2d95d
...
@@ -3,10 +3,7 @@ from board.models import Questboard
...
@@ -3,10 +3,7 @@ from board.models import Questboard
from
board.forms
import
QuestboardForm
from
board.forms
import
QuestboardForm
def
redirect_to_home
(
request
):
def
redirect_to_home
(
request
):
return
redirect
(
'home/'
)
return
redirect
(
'/home/'
)
def
return_previous_page
(
request
):
return
redirect
(
request
.
META
.
get
(
'HTTP_REFERER'
,
'/'
))
def
homepage_view
(
request
):
def
homepage_view
(
request
):
return
render
(
request
,
return
render
(
request
,
...
@@ -21,4 +18,4 @@ def add_questboard(request):
...
@@ -21,4 +18,4 @@ def add_questboard(request):
filled_form
=
QuestboardForm
(
request
.
POST
)
filled_form
=
QuestboardForm
(
request
.
POST
)
if
filled_form
.
is_valid
():
if
filled_form
.
is_valid
():
filled_form
.
save
()
filled_form
.
save
()
return
return_previous_page
(
request
)
return
redirect
(
request
.
META
.
get
(
'HTTP_REFERER'
,
'/'
))
\ No newline at end of file
\ No newline at end of file
project_questboard/urls.py
View file @
22d2d95d
...
@@ -5,4 +5,4 @@ urlpatterns = [
...
@@ -5,4 +5,4 @@ urlpatterns = [
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
''
,
include
(
'homepage.urls'
)),
path
(
''
,
include
(
'homepage.urls'
)),
path
(
'questboard/'
,
include
(
'board.urls'
)),
path
(
'questboard/'
,
include
(
'board.urls'
)),
]
]
\ No newline at end of file
templates/board/edit_board.html
View file @
22d2d95d
...
@@ -9,22 +9,12 @@
...
@@ -9,22 +9,12 @@
{% block header %}{{questboard.name}}{% endblock %}
{% block header %}{{questboard.name}}{% endblock %}
{% block content %}
{% block content %}
<button
onclick=
"showAddQuest()"
>
Add Quest
</button>
<dialog
id=
"add_quest"
>
<!-- PLEASE PREVENT NEGATIVE NUMBERS!!!-->
Required Stars: {{questboard.required_stars}}
<br/>
<form
action =
"add_quest"
method =
"post"
>
{{questboard.description}}
<br/>
{% csrf_token %}
{{ add_quest_form }}
<button
type=
"submit"
>
Add
</button>
</form>
<button
onclick =
"closeAllDialogBoxes()"
>
Cancel
</button>
</dialog>
{% if quests %}
{% if quests %}
Quests in the Questboard:
Quests in the Questboard:
<ul>
<ul>
{% for quest in quests %}
{% for quest in quests %}
...
@@ -33,6 +23,18 @@
...
@@ -33,6 +23,18 @@
<ul>
<ul>
{% endif %}
{% endif %}
<button
onclick=
"showAddQuest()"
>
Add Quest
</button>
<dialog
id=
"add_quest"
>
<form
action =
"/questboard/edit/add_quest/"
method =
"post"
>
{% csrf_token %}
{{ add_quest_form }}
<button
type=
"submit"
>
Add
</button>
</form>
<button
onclick =
"closeAllDialogBoxes()"
>
Cancel
</button>
</dialog>
{% endblock %}
{% endblock %}
{% block scripts %}
{% block scripts %}
...
...
templates/homepage/homepage.html
View file @
22d2d95d
...
@@ -12,17 +12,29 @@
...
@@ -12,17 +12,29 @@
{% block content %}
{% block content %}
{% for board in boards %}
<!-- LIST OF QUESTBOARDS -->
{{ board.name }}
<br/>
<table
class =
"board_table"
>
{{ board.description }}
<br/>
<tr>
{{ board.required_stars }}
<br/>
<th>
Questboard Name
</th>
<br/>
<th>
Actions
</th>
{% endfor %}
</tr>
{% for board in boards %}
<tr>
<td>
{{ board.name }}
</td>
<td>
<a
href =
"/questboard/edit/{{ board.pk }}"
>
<button
class =
"button"
>
Edit Questboard
</button>
</a>
</td>
</tr>
{% endfor %}
</table>
<button
class =
"button"
onclick =
"showAddBoard()"
>
Add a Questboard
</button>
<button
class =
"button"
onclick =
"showAddBoard()"
>
Add a Questboard
</button>
<dialog
id=
"add_board"
>
<dialog
id=
"add_board"
>
<!-- PLEASE PREVENT NEGATIVE NUMBERS!!!-->
<form
action =
"add_board/"
method =
"post"
>
<form
action =
"add_board/"
method =
"post"
>
{% csrf_token %}
{% csrf_token %}
{{ add_board_form }}
{{ add_board_form }}
...
...
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