Skip to content

Completed courses and email validation #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Binary file not shown.
Empty file.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
Binary file not shown.
7 changes: 7 additions & 0 deletions jessica_hart/assignments/Django/courses/apps/main_app/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from __future__ import unicode_literals

from django.apps import AppConfig


class MainAppConfig(AppConfig):
name = 'main_app'
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-03-20 01:02
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Comment',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('text', models.TextField()),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
],
),
migrations.CreateModel(
name='Course',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
],
),
migrations.CreateModel(
name='Description',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('text', models.TextField(default='N/A')),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('course', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='desc', to='main_app.Course')),
],
),
migrations.AddField(
model_name='comment',
name='course_id',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments', to='main_app.Course'),
),
]
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-03-20 01:05
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('main_app', '0001_initial'),
]

operations = [
migrations.RemoveField(
model_name='comment',
name='course_id',
),
migrations.RemoveField(
model_name='description',
name='course',
),
migrations.AddField(
model_name='course',
name='desc',
field=models.CharField(default='NA', max_length=400),
preserve_default=False,
),
migrations.DeleteModel(
name='Comment',
),
migrations.DeleteModel(
name='Description',
),
]
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-03-20 01:12
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('main_app', '0002_auto_20170320_0105'),
]

operations = [
migrations.AlterField(
model_name='course',
name='desc',
field=models.CharField(default='N/A', max_length=400),
),
]
Binary file not shown.
Binary file not shown.
31 changes: 31 additions & 0 deletions jessica_hart/assignments/Django/courses/apps/main_app/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from __future__ import unicode_literals
from django.db import models

class Course(models.Model):
name = models.CharField(max_length = 200)
desc = models.CharField(max_length = 400, default = 'N/A')
created_at = models.DateTimeField(auto_now_add = True)
updated_at = models.DateTimeField(auto_now = True)

def __str__(self): # By default return the course name
return self.name

# # Make Description a one-to-one relationship with the Course table rather than a column
# class Description(models.Model):
# course = models.OneToOneField(Course, related_name = 'desc')
# text = models.TextField(default = 'N/A')
# created_at = models.DateTimeField(auto_now_add = True)
# updated_at = models.DateTimeField(auto_now = True)
#
# def __str__(self): # By default return the description text
# return self.text
#
# # Add comments about the courses that will be rendered on a separate page
# class Comment(models.Model):
# course_id = models.ForeignKey(Course, related_name = 'comments')
# text = models.TextField()
# created_at = models.DateTimeField(auto_now_add = True)
# updated_at = models.DateTimeField(auto_now = True)
#
# def __str__(self): # By default return the comment text
# return self.text
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
@import url(http://fonts.googleapis.com/css?family=Roboto:400,500,700,300,100);
* {
padding: 0px;
margin: 0px;
}
body {
background-color: #3e94ec;
font-family: "Roboto", helvetica, arial, sans-serif;
font-size: 16px;
font-weight: 300;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}
#wrapper {
margin: 50px auto;
width: 960px;
}
#content {
background: rgba(255,255,255,0.15);
border: 1px solid rgba(255,255,255,0.25);
border-radius: 4px;
padding: 20px;
}
#form {
color: #1B1E24;
display: block;
margin-bottom: 20px;
text-align: top;
}
#form .col {
display: inline-block;
padding-right: 20px;
vertical-align: top;
}
#form .col:last-child {
width: 400px;
}
#form li {
display: block;
margin: 8px 5px 25px 0px;
}
#buttons {
display: block;
text-align: center;
}
#buttons input[type=submit] {
float: none;
margin-left: 20px;
}
h1 {
color: #fafafa;
font-size: 30px;
font-style: normal;
font-weight: 300;
}
h1, ul {
margin-bottom: 15px;
}

a {
color: #1B1E24;
}
input[type=text] {
width: 95.5%;
}
textarea {
width: 96%;
}
input[type=text], textarea {
font-size: 14px;
margin: 5px;
padding: 5px;
}
input[type=submit] {
color:#1B1E24;
font-weight: 300;
font-size:16px;
float: right;
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
padding: 8px 12px;
background-color: #EBEBEB;
border: 2px solid #9EA7AF;
border-radius: 3px;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}
input[type=submit]:hover {
color: #fafafa;
background-color: #4E5066;
border: 2px solid #1B1E24;
}
/* ======================
Messages Block
====================== */
.messages li {
color: #fafafa;
display: block;
border: 1px solid rgba(255,255,255,0.25);
border-radius: 4px;
padding: 10px;
text-align: center;
}
.success {
background-color: #66cc91;
}
.error {
background-color: #e74c3c;
}
/* ======================
Tables Styles
====================== */
/** Table Styles from http://codepen.io/alassetter/pen/cyrfB **/
table {
background: white;
border-radius: 3px;
border-collapse: collapse;
padding: 5px;
width: 100%;
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
animation: float 5s infinite;
}
th {
color: #D5DDE5;
background: #1b1e24;
border-bottom:4px solid #9ea7af;
border-right: 1px solid #343a45;
font-size:23px;
font-weight: 100;
padding:24px;
text-align:left;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
vertical-align: middle;
}
th:first-child {
border-top-left-radius:3px;
}
th:last-child {
border-top-right-radius:3px;
border-right:none;
}
tr {
border-top: 1px solid #C1C3D1;
border-bottom-: 1px solid #C1C3D1;
color:#666B85;
font-size:16px;
font-weight:normal;
text-shadow: 0 1px 1px rgba(256, 256, 256, 0.1);
}
tr:hover td {
background:#4E5066;
color:#FFFFFF;
border-top: 1px solid #22262e;
border-bottom: 1px solid #22262e;
}
tr:hover td a {
color: #C1C3D1;
}
tr:first-child {
border-top:none;
}
tr:last-child {
border-bottom:none;
}
tr:nth-child(odd) td {
background:#EBEBEB;
}
tr:nth-child(odd):hover td {
background:#4E5066;
}
tr:last-child td:first-child {
border-bottom-left-radius:3px;
}
tr:last-child td:last-child {
border-bottom-right-radius:3px;
}
td {
background:#FFFFFF;
padding:20px;
text-align:left;
vertical-align:middle;
font-weight:300;
font-size:18px;
text-shadow: -1px -1px 1px rgba(0, 0, 0, 0.1);
border-right: 1px solid #C1C3D1;
}
td:last-child {
border-right: 0px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
{% load staticfiles %}
<head>
<meta charset="utf-8">
<title>Courses</title>
<link rel="stylesheet" href="{% static 'main_app/css/style.css' %}">
</head>
<body>
<div id="wrapper">
{% if messages %}
<ul class="messages">
{% for message in messages %}
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
<div id="content">
{% block content %}
{% endblock %}
</div>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% extends 'main_app/base.html' %}

{% block content %}
<h1>Are you sure you want to delete the following course?</h1>
<div id="form">
<form action="/courses/destroy/confirm/{{ course.id }}" method="post">
{% csrf_token %}
<div class="col">
<ul>
<li>Name:</li>
<li>Description:</li>
</ul>
</div>
<div class="col">
<ul>
<li>{{ course }}</li>
<li>{{ course.desc }}</li>
</ul>
</div>
<div id="buttons">
<input type="submit" name="action" value="No">
<input type="submit" name="action" value="Yes! I want to delete this">
</div>
</form>
</div>
{% endblock %}
Loading