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

Merge branch 'assignmentsv2' into 'master'

Assignmentsv2

See merge request !10
parents 4d36ecb3 1fa802ca
SECRET_KEY = 'django-insecure-0ne3r+4_-4wxim9e1!jkyw8%fnii1af4pc$irxf%nvrs3wp*1f'
\ No newline at end of file
from django.db import models
from django.urls import reverse
class Course(models.Model):
......@@ -24,6 +25,9 @@ class Assignment(models.Model):
Course/Section: {}<br>""".format(self.name, self.description, self.perfect_score,
self.passing_score, self.course)
def get_absolute_url(self):
return reverse('assignments:assignment-details', kwargs={'pk':self.pk})
@property
def passing_score(self):
return round(self.perfect_score*6/10)
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}Add Assigment{% endblock %}
{% block content %}
<form action="" method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save New Assigment">
</form>
{% endblock %}
{% block scripts %}
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}{{ assignment.name }}{% endblock %}
{% block content %}
<h1>{{ assignment.name }}</h1>
<h3>{{ assignment.course}}<br>
Description: {{ assignment.description }}<br>
Perfect Score: {{ assignment.perfect_score }}<br>
Passing Score: {{ assignment.passing_score }}<br>
</h3>
{% endblock %}
{% block scripts %}
<a href="/assignments/{{ assignment.pk }}/edit"><input type="submit" value="Edit Assignment"></a>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}Edit Book{% endblock %}
{% block content %}
<form action="" method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save Changes to Assignment">
</form>
{% endblock %}
{% block scripts %}
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}Widget's Assignments{% endblock %}
{% block content %}
<h1>Welcome to Widget's Assignments!</h1>
<h3>
{% for assignment in assignments %}
<a href="{{ assignment.get_absolute_url }}">{{ assignment.name }}</a><br>
{% endfor %}
</h3>
{% endblock %}
{% block scripts %}
<a href="/assignments/add"><input type="submit" value="New Assignment"></a><br><br>
<a href="/dashboard">Dashboard</a><br>
<a href="/announcement">Announcements</a><br>
<a href="/forum">Forum</a><br>
<a href="/calendar">Calendar</a>
{% endblock %}
\ No newline at end of file
from django.contrib import admin
from django.urls import path
from .views import index
from .views import index, AssignmentDetailView, AssignmentCreateView, AssignmentUpdateView
urlpatterns = [
path('', index, name='index'),
path('<int:pk>/details', AssignmentDetailView.as_view(), name='assignment-details'),
path('add/', AssignmentCreateView.as_view(), name='add-assignment'),
path('<int:pk>/edit', AssignmentUpdateView.as_view(), name='edit-assignment'),
]
app_name = "assignments"
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import Assignment
def index(request):
page_content = "<H1>Widget's Assignments Page</H1><ul>"
for assignment in Assignment.objects.all():
page_content += "<li>{}<br>".format(assignment)
return HttpResponse(page_content)
\ No newline at end of file
return render(request, 'assignments/assignments.html', {'assignments': Assignment.objects.all()})
class AssignmentDetailView(DetailView):
model = Assignment
def get(self, request, pk):
return render(request, 'assignments/assignment-details.html', {'assignment': self.model.objects.get(pk=pk)})
class AssignmentCreateView(CreateView):
model = Assignment
fields = '__all__'
template_name = 'assignments/assignment-add.html'
class AssignmentUpdateView(UpdateView):
model = Assignment
fields = '__all__'
template_name = 'assignments/assignment-edit.html'
\ No newline at end of file
No preview for this file type
<html lang="en">
<head>
<title>{% block title %}{% endblock %}</title>
</head>
<body>
<div id="content">
{% block content %}{% endblock %}
</div>
{% block scripts %}{% endblock %}
</body>
</html>
\ No newline at end of file
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'widget_calendar.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
"""
ASGI config for widget_calendar project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'widget_calendar.settings')
application = get_asgi_application()
"""
Django settings for widget_calendar project.
Generated by 'django-admin startproject' using Django 4.1.7.
For more information on this file, see
https://docs.djangoproject.com/en/4.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# 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-)oxt+se5kgp*!w3t*%4w!_=$*%^qzbe_$3_q$xay(m&uk*i(r='
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'widget_calendar.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'widget_calendar.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/4.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/
STATIC_URL = 'static/'
# Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
"""widget_calendar 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
urlpatterns = [
path('admin/', admin.site.urls),
]
"""
WSGI config for widget_calendar project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'widget_calendar.settings')
application = get_wsgi_application()
......@@ -64,7 +64,7 @@ ROOT_URLCONF = 'widget_k3git.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
......
......@@ -3,7 +3,7 @@ from django.urls import include, path
urlpatterns = [
path('announcement/', include('announcement.urls', namespace="announcement")),
path('widget_calendar/', include('widget_calendar.urls', namespace="widget_calendar")),
path('calendar/', include('widget_calendar.urls', namespace="widget_calendar")),
path('assignments/', include('assignments.urls', namespace="assignments")),
path('dashboard/', include('dashboard.urls', namespace="dashboard")),
path('forum/', include('forum.urls', namespace="forum")),
......
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