Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_vincentdjango
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
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Almira Redoble
midterm_vincentdjango
Commits
e3adc642
Commit
e3adc642
authored
Mar 05, 2023
by
Star Neptune R. Sy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migrated the models
parent
37818654
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
7 deletions
+77
-7
0001_initial.py
widget_vincentdjango/assignments/migrations/0001_initial.py
+35
-0
models.py
widget_vincentdjango/assignments/models.py
+10
-6
views.py
widget_vincentdjango/assignments/views.py
+32
-1
db.sqlite3
widget_vincentdjango/db.sqlite3
+0
-0
No files found.
widget_vincentdjango/assignments/migrations/0001_initial.py
0 → 100644
View file @
e3adc642
# Generated by Django 3.2 on 2023-03-05 06:23
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
initial
=
True
dependencies
=
[
]
operations
=
[
migrations
.
CreateModel
(
name
=
'Course'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'course_code'
,
models
.
CharField
(
default
=
''
,
max_length
=
50
,
unique
=
True
)),
(
'course_title'
,
models
.
CharField
(
default
=
''
,
max_length
=
50
,
unique
=
True
)),
],
),
migrations
.
CreateModel
(
name
=
'Assignment'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'assignment_name'
,
models
.
CharField
(
default
=
''
,
max_length
=
50
,
unique
=
True
)),
(
'description'
,
models
.
TextField
(
default
=
''
)),
(
'perfect_score'
,
models
.
IntegerField
(
default
=
0
)),
(
'passing_score'
,
models
.
IntegerField
(
default
=
0
)),
(
'section'
,
models
.
CharField
(
max_length
=
16
,
unique
=
True
)),
(
'course'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'subject'
,
to
=
'assignments.course'
)),
],
),
]
widget_vincentdjango/assignments/models.py
View file @
e3adc642
...
@@ -2,16 +2,19 @@ from django.db import models
...
@@ -2,16 +2,19 @@ from django.db import models
class
Course
(
models
.
Model
):
class
Course
(
models
.
Model
):
course_code
=
models
.
CharField
(
unique
=
True
,
default
=
""
)
course_code
=
models
.
CharField
(
unique
=
True
,
default
=
""
,
max_length
=
50
,)
course_title
=
models
.
CharField
(
unique
=
True
,
default
=
""
)
course_title
=
models
.
CharField
(
unique
=
True
,
default
=
""
,
max_length
=
50
,)
def
__str__
(
self
):
return
'{} {}-'
.
format
(
self
.
course_code
,
self
.
course_title
,)
class
Assignment
(
models
.
Model
):
class
Assignment
(
models
.
Model
):
assignment_name
=
models
.
CharField
(
unique
=
True
,
default
=
""
)
assignment_name
=
models
.
CharField
(
unique
=
True
,
default
=
""
,
max_length
=
50
,
)
description
=
models
.
TextField
(
default
=
""
)
description
=
models
.
TextField
(
default
=
""
)
perfect_score
=
models
.
IntegerField
()
perfect_score
=
models
.
IntegerField
(
default
=
0
)
passing_score
=
models
.
IntegerField
()
passing_score
=
models
.
IntegerField
(
default
=
0
)
section
=
models
.
CharField
(
unique
=
True
)
section
=
models
.
CharField
(
unique
=
True
,
max_length
=
16
,
)
course
=
models
.
ForeignKey
(
course
=
models
.
ForeignKey
(
Course
,
Course
,
on_delete
=
models
.
CASCADE
,
on_delete
=
models
.
CASCADE
,
...
@@ -19,3 +22,4 @@ class Assignment(models.Model):
...
@@ -19,3 +22,4 @@ class Assignment(models.Model):
)
)
widget_vincentdjango/assignments/views.py
View file @
e3adc642
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
# Create your views here.
from
.models
import
Assignment
def
index
(
request
):
head
=
"<h1 style='border-bottom:4px solid lightgray;
\
padding-bottom:30px;
\
font-size:500
%
;'>
\
Welcome to Widget!
\
</h1>"
body
=
"<h2>WIDGET USERS:</h2>"
for
subject
in
Assignment
.
objects
.
all
():
body
+=
"<p style='border: 2px solid gray;
\
border-radius:5px;
\
padding:20px 30px;'>
\
Assignment Name: "
+
subject
.
assignment_name
+
" <br>
\
Description: "
+
subject
.
description
+
" <br>
\
Perfect Score: "
+
str
(
subject
.
perfect_score
)
+
" <br>
\
Passing Score: "
+
str
(
subject
.
passing_score
)
+
" <br>
\
Course/Section: "
+
str
(
subject
.
course
)
+
str
(
subject
.
section
)
+
" <br>
\
</p>"
return_string
=
"<html>
\
<body style = 'font-family:helvetica;
\
padding:30px;'>
\
{}{}
\
</body></html>"
.
format
(
head
,
body
)
return
HttpResponse
(
return_string
)
widget_vincentdjango/db.sqlite3
View file @
e3adc642
No preview for this file type
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