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
0de6c440
Commit
0de6c440
authored
Apr 09, 2021
by
Aedin Hunter A. Clay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
can now view and add questboards in the homepage
parent
834b656a
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
91 additions
and
4 deletions
+91
-4
0001_initial.py
board/migrations/0001_initial.py
+37
-0
urls.py
homepage/urls.py
+2
-1
views.py
homepage/views.py
+16
-2
homepage.html
templates/homepage/homepage.html
+36
-1
No files found.
board/migrations/0001_initial.py
0 → 100644
View file @
0de6c440
# Generated by Django 3.1.7 on 2021-04-09 04:55
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
initial
=
True
dependencies
=
[
]
operations
=
[
migrations
.
CreateModel
(
name
=
'Quest'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'board_pk'
,
models
.
IntegerField
(
default
=
0
)),
(
'name'
,
models
.
CharField
(
default
=
''
,
max_length
=
60
)),
(
'description'
,
models
.
CharField
(
default
=
''
,
max_length
=
300
)),
(
'stars'
,
models
.
IntegerField
(
default
=
0
)),
(
'for_everyone'
,
models
.
BooleanField
(
default
=
False
)),
(
'student1'
,
models
.
CharField
(
default
=
''
,
max_length
=
60
)),
(
'student2'
,
models
.
CharField
(
default
=
''
,
max_length
=
60
)),
(
'student3'
,
models
.
CharField
(
default
=
''
,
max_length
=
60
)),
],
),
migrations
.
CreateModel
(
name
=
'Questboard'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'name'
,
models
.
CharField
(
max_length
=
50
)),
(
'description'
,
models
.
CharField
(
max_length
=
300
)),
(
'required_stars'
,
models
.
IntegerField
()),
],
),
]
homepage/urls.py
View file @
0de6c440
...
...
@@ -5,4 +5,5 @@ from . import views
urlpatterns
=
[
path
(
''
,
views
.
redirect_to_home
),
path
(
'home/'
,
views
.
homepage_view
),
path
(
'home/add_board/'
,
views
.
add_questboard
),
]
homepage/views.py
View file @
0de6c440
from
django.shortcuts
import
redirect
,
render
from
board.models
import
Questboard
f
or
m
board
.
forms
import
QuestboardForm
f
ro
m
board.forms
import
QuestboardForm
def
redirect_to_home
(
request
):
return
redirect
(
'home/'
)
def
return_previous_page
(
request
):
return
redirect
(
request
.
META
.
get
(
'HTTP_REFERER'
,
'/'
))
def
homepage_view
(
request
):
return
render
(
request
,
'homepage/homepage.html'
)
return
render
(
request
,
'homepage/homepage.html'
,
{
'boards'
:
Questboard
.
objects
.
all
(),
'add_board_form'
:
QuestboardForm
(),
})
def
add_questboard
(
request
):
if
request
.
method
==
"POST"
:
filled_form
=
QuestboardForm
(
request
.
POST
)
if
filled_form
.
is_valid
():
filled_form
.
save
()
return
return_previous_page
(
request
)
\ No newline at end of file
templates/homepage/homepage.html
View file @
0de6c440
...
...
@@ -11,5 +11,40 @@
{% block content %}
nothing so far
{% for board in boards %}
{{ board.name }}
<br/>
{{ board.description }}
<br/>
{{ board.required_stars }}
<br/>
<br/>
{% endfor %}
<button
class =
"button"
onclick =
"showAddBoard()"
>
Add a Questboard
</button>
<dialog
id=
"add_board"
>
<form
action =
"add_board/"
method =
"post"
>
{% csrf_token %}
{{ add_board_form }}
<button
type=
"submit"
>
Add
</button>
</form>
<button
onclick =
"closeAllDialogBoxes()"
>
Cancel
</button>
</dialog>
{% endblock %}
{% block scripts %}
<script>
AddBoard
=
document
.
getElementById
(
"add_board"
);
function
closeAllDialogBoxes
(){
AddBoard
.
close
();
}
function
showAddBoard
(){
closeAllDialogBoxes
();
AddBoard
.
show
();
}
</script>
{% 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