Commit a33d1373 authored by Nate Brevin A. Que's avatar Nate Brevin A. Que

Created the Assignments page and its models, and updated the project's settings.

parent a3222ac8
SECRET_KEY = 'django-insecure-0ne3r+4_-4wxim9e1!jkyw8%fnii1af4pc$irxf%nvrs3wp*1f'
\ No newline at end of file
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class AssignmentsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'assignments'
# Generated by Django 3.2 on 2023-03-01 14:37
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')),
('code', models.CharField(max_length=10)),
('title', models.CharField(max_length=100)),
('section', models.CharField(max_length=3)),
],
),
migrations.CreateModel(
name='Assignment',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('description', models.TextField()),
('perfect_score', models.IntegerField()),
('passing_score', models.IntegerField()),
('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assignments.course')),
],
),
]
from django.db import models
class Course(models.Model):
code = models.CharField(max_length=10)
title = models.CharField(max_length=100)
section = models.CharField(max_length=3)
class Assignment(models.Model):
name = models.CharField(max_length=100)
description = models.TextField()
course = models.ForeignKey(Course, on_delete=models.CASCADE)
perfect_score = models.IntegerField()
passing_score = models.IntegerField()
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.contrib import admin
from django.urls import path
from .views import index
urlpatterns = [
path('', index, name='index'),
]
app_name = "assignments"
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
def index(request):
return HttpResponse("""<H1>Widget's Assignments Page</H1><br>
<H2><ul>
<li>Assignment Name: </li>
<li>Description: </li>
<li>Perfect Score: </li>
<li>Passing Score: </li>
<li>Course/Section: </li>
</H2>
""")
\ No newline at end of file
......@@ -10,7 +10,12 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""
import os
from pathlib import Path
from dotenv import load_dotenv
load_dotenv()
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
......@@ -20,7 +25,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-0ne3r+4_-4wxim9e1!jkyw8%fnii1af4pc$irxf%nvrs3wp*1f'
SECRET_KEY = os.getenv('SECRET_KEY')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
......@@ -37,6 +42,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'assignments',
]
MIDDLEWARE = [
......
"""widget_k3git URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import include, path
urlpatterns = [
path('assignments/', include('assignments.urls', namespace="assignments")),
path('admin/', admin.site.urls),
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment