Commit a51fafe6 authored by Alessandro Olivar's avatar Alessandro Olivar

Adding things to gitingore

parents
#!/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', 'mysite.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 mysite 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/3.1/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
application = get_asgi_application()
"""
Django settings for mysite project.
Generated by 'django-admin startproject' using Django 3.1.7.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.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/3.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'j+*r9li+#+#ec9@x!cx=of^f+w4=+(t@vq0vo1in-sdy#ws3f$'
# 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',
'qBoard',
]
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 = 'mysite.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 = 'mysite.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/3.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/3.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/
STATIC_URL = '/static/'
"""mysite URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.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, include
from django.http import HttpResponse
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('qBoard.urls')),
]
"""
WSGI config for mysite 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/3.1/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
application = get_wsgi_application()
from django.contrib import admin
# Register your models here.
from .models import *
admin.site.register(QBoard)
admin.site.register(Quest)
\ No newline at end of file
from django.apps import AppConfig
class QboardConfig(AppConfig):
name = 'qBoard'
from django.forms import ModelForm
from .models import *
class QBoardForm(ModelForm):
class Meta:
model = QBoard
fields = '__all__'
class QuestForm(ModelForm):
class Meta:
model = Quest
fields = '__all__'
\ No newline at end of file
# Generated by Django 3.1.7 on 2021-12-14 07:43
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='qBoard',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200)),
],
),
]
# Generated by Django 3.1.7 on 2021-12-14 13:27
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('qBoard', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='quest',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200, null=True)),
('desc', models.CharField(max_length=200, null=True)),
('stars', models.CharField(max_length=200, null=True)),
('student1', models.CharField(max_length=200, null=True)),
('student2', models.CharField(max_length=200, null=True)),
('student3', models.CharField(max_length=200, null=True)),
],
),
migrations.AddField(
model_name='qboard',
name='desc',
field=models.CharField(max_length=200, null=True),
),
migrations.AddField(
model_name='qboard',
name='stars',
field=models.CharField(max_length=200, null=True),
),
migrations.AlterField(
model_name='qboard',
name='name',
field=models.CharField(max_length=200, null=True),
),
]
# Generated by Django 3.1.7 on 2021-12-15 01:40
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('qBoard', '0002_auto_20211214_2127'),
]
operations = [
migrations.AddField(
model_name='quest',
name='qBoard',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='qBoard.qboard'),
),
]
# Generated by Django 3.1.7 on 2021-12-15 09:02
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('qBoard', '0003_quest_qboard'),
]
operations = [
migrations.RenameField(
model_name='quest',
old_name='qBoard',
new_name='QBoard',
),
migrations.AlterField(
model_name='qboard',
name='desc',
field=models.CharField(blank=True, max_length=200, null=True),
),
migrations.AlterField(
model_name='quest',
name='desc',
field=models.CharField(blank=True, max_length=200, null=True),
),
]
# Generated by Django 3.1.7 on 2021-12-16 07:46
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('qBoard', '0004_auto_20211215_1702'),
]
operations = [
migrations.RenameField(
model_name='quest',
old_name='QBoard',
new_name='qboard',
),
]
from django.db import models
# Create your models here.
class QBoard(models.Model):
name = models.CharField(max_length = 200, null = True)
desc = models.CharField(max_length = 200, null = True, blank = True)
stars = models.CharField(max_length = 200, null = True)
def __str__(self):
return self.name
class Quest(models.Model):
qboard = models.ForeignKey(QBoard, null = True, on_delete = models.SET_NULL)
name = models.CharField(max_length = 200, null = True)
desc = models.CharField(max_length = 200, null = True, blank = True)
stars = models.CharField(max_length = 200, null = True)
student1 = models.CharField(max_length = 200, null = True)
student2 = models.CharField(max_length = 200, null = True)
student3 = models.CharField(max_length = 200, null = True)
def __str__(self):
return self.name
\ No newline at end of file
{% extends 'qBoard/main.html' %}
{% block content %}
<h1>Homepage</h1>
<div class="row">
<div class="col-md-5">
<h5>QUESTBOARDS</h5>
<hr>
<a class="btn btn-primary btn-sm btn-block" href="{% url 'create_qboard' %}">New Questboard</a>
<hr>
{% for i in qboards %}
<div class="card card-body">
<a class="btn btn-primary btn-sm btn-block" href="{% url 'questboard' i.id %}">Go</a>
<table class="table table-sm">
<tr>
<th class="text-center">{{i.name}}</th>
</tr>
</table>
</div>
{% endfor %}
</div>
</div>
{% endblock %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
{% include 'qBoard/navbar.html' %}
{% block content %}{% endblock %}
</body>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</html>
\ No newline at end of file
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="/">Homepage</a>
</li>
</ul>
</div>
</nav>
\ No newline at end of file
{% extends 'qBoard/main.html' %}
{% block content %}
<form action = "" method = "POST">
{% csrf_token %}
{{form}}
<input type = "submit" name = "Submit">
</form>
{% endblock %}
\ No newline at end of file
{% extends 'qBoard/main.html' %}
{% block content %}
<form action = "" method = "POST">
{% csrf_token %}
{{form}}
<input type = "submit" name = "Submit">
</form>
{% endblock %}
\ No newline at end of file
{% extends 'qBoard/main.html' %}
{% block content %}
<div class="row">
<div class="col-md-5">
<h1>{{qboard.name}}</h1>
<hr>
<p>
"Each group should collect {{qboard.stars}} stars to fulfill the requirements for {{qboard.name}}"
</p>
<hr>
<p>
{{qboard.desc}}
</p>
<hr>
<a class="btn btn-primary btn-sm btn-block" href="{% url 'update_qboard' qboard.id %}">Edit QuestBoard</a>
<!--<a class="btn btn-primary btn-sm btn-block" href="">Delete QuestBoard</a>-->
<hr>
<a class="btn btn-primary btn-sm btn-block" href="{% url 'create_quest' qboard.id %}">New Quest</a>
<hr>
{% for quest in quests %}
<div class="card card-body">
<table>
<tr>
<td><a class="btn btn-primary btn-sm btn-block" href="{% url 'update_quest' qboard.id %}">Edit Quest</a></td>
<!--<td><a class="btn btn-primary btn-sm btn-block" href="">Delete Quest</a></td>-->
</tr>
</table>
<table class="table table-sm">
<tr>
<th colspan = 3 class="text-center">{{quest.name}}</th>
</tr>
<tr>
<td colspan = 3 class="text-center"><p>{{quest.desc}}</p></td>
</tr>
<tr>
<td rowspan = 3>Dibs:</td>
<td colspan = 2 class="text-left">{{quest.student1}}</td>
</tr>
<tr>
<td colspan = 2 class="text-left">{{quest.student2}}</td>
</tr>
<tr>
<td colspan = 2 class="text-left">{{quest.student3}}</td>
</tr>
<tr>
<td colspan = 3 class="text-center">{{quest.stars}}</td>
</tr>
</table>
</div>
{% endfor %}
</div>
</div>
{% endblock %}
from django.test import TestCase
# Create your tests here.
from django.urls import path
from . import views
urlpatterns = [
path('', views.home, name = "home"),
path('questboard/<str:pk_test>/', views.quests, name = "questboard"),
path('create_qboard/', views.createQBoard, name = "create_qboard"),
path('update_qboard/<str:pk>/', views.updateQBoard, name = "update_qboard"),
path('create_quest/<str:pk>/', views.createQuest, name = "create_quest"),
path('update_quest/<str:pk>/', views.updateQuest, name = "update_quest"),
]
\ No newline at end of file
from django.shortcuts import render, redirect
from django.http import HttpResponse
# Create your views here.
from .models import *
from .forms import *
def home(request):
qboards = QBoard.objects.all()
context = {'qboards' : qboards}
return render(request,'qBoard/homepage.html', context)
def quests(request, pk_test):
qboard = QBoard.objects.get(id = pk_test)
quests = qboard.quest_set.all()
context = {'qboard' : qboard, 'quests' : quests}
return render(request, 'qBoard/quests.html', context)
def createQBoard(request):
form = QBoardForm()
if request.method == 'POST':
form = QBoardForm(request.POST)
if form.is_valid():
form.save()
return redirect('/')
context = {'form':form}
return render(request, 'qBoard/qboard_form.html', context)
def updateQBoard(request, pk):
qboard = QBoard.objects.get(id = pk)
form = QBoardForm(instance = qboard)
if request.method == 'POST':
form = QBoardForm(request.POST, instance = qboard)
if form.is_valid():
form.save()
return redirect('/')
context = {'form':form}
return render(request, 'qBoard/qboard_form.html', context)
def createQuest(request, pk):
questboard = QBoard.objects.get(id = pk)
form = QuestForm(initial = {'qboard':questboard})
if request.method == 'POST':
form = QuestForm(request.POST)
if form.is_valid():
form.save()
return redirect('/')
context = {'form':form}
return render(request, 'qBoard/quest_form.html', context)
def updateQuest(request, pk):
questboard = QBoard.objects.get(id = pk)
quest = Quest.objects.get(id = pk)
form = QuestForm(initial = {'qboard':questboard}, instance = quest)
if request.method == 'POST':
form = QuestForm(request.POST, instance = quest)
if form.is_valid():
form.save()
return redirect('/')
context = {'form':form}
return render(request, 'qBoard/quest_form.html', context)
\ No newline at end of file
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