Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #75 from DHRI-Curriculum/kallewesterling/issue68
Browse files Browse the repository at this point in the history
Addresses #68 and beyond
  • Loading branch information
kallewesterling authored Jun 25, 2020
2 parents f1b98d3 + 99476a8 commit ac788d5
Show file tree
Hide file tree
Showing 19 changed files with 160 additions and 63 deletions.
2 changes: 1 addition & 1 deletion app/frontmatter/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __str__(self):


class LearningObjective(models.Model):
frontmatter = models.ForeignKey(Frontmatter, on_delete=models.CASCADE)
frontmatter = models.ForeignKey(Frontmatter, on_delete=models.CASCADE, related_name="learning_objectives")
label = models.TextField(max_length=500)

def __str__(self):
Expand Down
3 changes: 2 additions & 1 deletion app/website/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.contrib import admin
from .models import Page

# Register your models here.
admin.site.register(Page)
6 changes: 4 additions & 2 deletions app/website/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from workshop.models import Workshop
from website.models import Page

from pathlib import Path

def add_to_all_contexts(request):
context_data = dict()

context_data['footer'] = dict()
context_data['footer']['workshops'] = Workshop.objects.all()
context_data['website'] = dict()
context_data['website']['workshops'] = Workshop.objects.all()
context_data['website']['pages'] = Page.objects.all()

return context_data
9 changes: 8 additions & 1 deletion app/website/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
from django.db import models

# Create your models here.
class Page(models.Model):
name = models.CharField(max_length=200)
slug = models.CharField(max_length=200, blank=True)
text = models.TextField()
is_homepage = models.BooleanField(default=False)

def __str__(self):
return str(self.name)
1 change: 1 addition & 0 deletions app/website/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@

urlpatterns = [
path('', views.index, name='index'),
path('<str:page_slug>/', views.page, name='page'),
]
12 changes: 10 additions & 2 deletions app/website/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
from django.shortcuts import render
from django.shortcuts import render, get_object_or_404
from .models import Page

def index(request):
return render(request, 'website/index.html', {})
print('index!')
page = Page.objects.filter(is_homepage=True).last()
return render(request, 'website/index.html', {'page': page})

def page(request, page_slug):
print('page!')
page = get_object_or_404(Page, slug=page_slug)
return render(request, 'website/index.html', {'page': page})
35 changes: 35 additions & 0 deletions app/workshop/static/website/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,39 @@ blockquote {

.dhri-hero:hover {
color: #d1d6d7 !important;
}

.special-link {
background-color: #2C3E50 !important;
}

.special-link:hover {
background-color: #2c3e5097 !important;
}

.special-link-disabled {
background-color: #2c3e5097 !important;
}

.uppercase {
text-transform: uppercase;
}

.lesson-text {
font-size:1.2rem;
line-height:2rem;
}

.lesson-text code {
padding-left: 0.15em;
padding-right: 0.15em;
padding-top: 0em;
padding-bottom: 0em;
margin: 0;
display: inline-block;
background-color: rgba(255, 0, 255, 0.01) !important;
}

.lesson-text kbd {
background-color: rgba(17, 45, 45, 0.529);
}
25 changes: 19 additions & 6 deletions app/workshop/templates/lesson/lesson-elements/pagination.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
<nav aria-label="Page navigation example">
<nav aria-label="Lesson navigation">
<ul class="pagination justify-content-center justify-content-sm-end">
<li class="page-item disabled">
<a class="page-link" href="#" tabindex="-1" aria-disabled="true">Previous</a>
<a class="page-link special-link-disabled" href="#" tabindex="-1" aria-disabled="true">Previous</a>
</li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item">
<a class="page-link" href="#">Next</a>
<a class="page-link special-link" href="#">1</a></li>
<li class="page-item">
<a class="page-link special-link" href="#">2</a></li>
<li class="page-item">
<a class="page-link special-link" href="#">3</a></li>
<li class="page-item">
<a class="page-link special-link" href="#">4</a></li>
<li class="page-item">
<a class="page-link special-link" href="#">5</a></li>
<li class="page-item">
<a class="page-link special-link" href="#">6</a></li>
<li class="page-item">
<a class="page-link special-link" href="#">7</a></li>
<li class="page-item">
<a class="page-link special-link" href="#">8</a></li>
<li class="page-item">
<a class="page-link special-link" href="#">Next</a>
</li>
</ul>
</nav>
58 changes: 54 additions & 4 deletions app/workshop/templates/lesson/lesson.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,64 @@

{% block main %}
<div class="row pt-5">
<div class="col-12">
<h2>Contents for lesson here!</h2>

<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</p>
<p>But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?</p>
<div class="col-12 py-3">
<h2>Conditionals</h2>

<div class="lesson-text py-3">
<p>Conditionals allow programs to change their behavior based on whether some statement is true or false. Let's try this out by writing a script that will give different outputs based on the weather:</p>

<blockquote>
<code>
<p>weather = "sunny"</p>

<p>if weather == "sunny":</p>
<p>&nbsp;&nbsp;print("Bring your shades")</p>
<p>else:</p>
<p>&nbsp;&nbsp;print("I don't know what you should bring! I'm just a little program...")</p>
</code>
</blockquote>

<p>In our first line, we set a variable <kbd>weather</kbd> to the string "sunny," representing what the weather is like outside. The <kbd>if</kbd> statement checks whether the variable weather is set to "sunny." If it is, the code in the block beneath is executed, so the text "Bring your shades" will be printed.</p>

<p>The <kbd>else</kbd> statement handles any inputs that aren't "sunny"—the program merely prints out that it doesn't know what you should bring. Try this script out both with the variable set to "sunny" and the variable set to some other value.</p>

<p>What if we want our program to handle other kinds of weather, giving different messages for each one? Other cases after the first <kbd>if</kbd> statement are handled with <kbd>elif</kbd>:</p>

<blockquote>
<code>
<p>weather = "sunny"</p>

<p>if weather == "sunny":</p>
<p>&nbsp;&nbsp;print("Bring your shades")
<p>elif weather == "rainy":</p>
<p>&nbsp;&nbsp;print("Bring your umbrella")
<p>elif weather == "snowy":</p>
<p>&nbsp;&nbsp;print("Bring your wooly muffler")
<p>else:</p>
<p>&nbsp;&nbsp;print("I don't know what you should bring! I'm just a little program...")</p>
</code>
</blockquote>

<p>You can add as many <kbd>elif</kbd> statements as you need, meaning that conditionals in Python have one <kbd>if</kbd> statement, any number of <kbd>elif</kbd> statements, and one <kbd>else</kbd> statement that catches any input not covered by <kbd>if</kbd> or <kbd>elif</kbd>. Over the next sections, we'll work on improving this little application, making it able to handle user input directly.</p>

<h3 class="pt-4">Challenge</h3>

<p>Add two more <kbd>elif</kbd> statements to this program to make it better able to handle different kinds of weather.</p>
</div>
</div>

</div>

{% include 'lesson/lesson-elements/pagination.html' %}
<div class="row pt-5">

<div class="col-12 py-3">
<h4 class="small uppercase">Workshop overall progress</h4>
<div class="progress">
<div class="progress-bar progress-bar-striped" role="progressbar" style="width: 10%" aria-valuenow="10" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
</div>

{% endblock %}
2 changes: 1 addition & 1 deletion app/workshop/templates/website/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

<title>Digital Humanities Research Institute - Curriculum Website</title>
<link href="https://fonts.googleapis.com/css?family=Titillium+Web:400,600,700" rel="stylesheet">
<link rel="stylesheet" href="{% static 'website/css/main.css' %}">
<link rel="stylesheet" href="{% static 'website/css/bootstrap-style.min.css' %}">
<link rel="stylesheet" href="{% static 'website/css/icons.css' %}">
<link rel="stylesheet" href="{% static 'website/css/main.css' %}">
</head>
<body>

Expand Down
2 changes: 1 addition & 1 deletion app/workshop/templates/website/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="col-6 col-md">
<h5>Workshops</h5>
<ul class="list-unstyled text-small">
{% for workshop in footer.workshops %}
{% for workshop in website.all_workshops %}
<li><a class="link-secondary" href="{% url 'workshop:frontmatter' slug=workshop.slug %}">{{ workshop.name }}</a></li>
{% endfor %}
</ul>
Expand Down
2 changes: 1 addition & 1 deletion app/workshop/templates/website/index-elements/hero.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<h1 class="dhri-hero">Digital Humanities Research Institute</h1>
<h1 class="display-4">Curriculum Website</h1>
<p class="lead">Introduction text here. Should probably live in website.models somehow.</p>
<p class="lead">{{ page.text }}</p>
2 changes: 1 addition & 1 deletion app/workshop/templates/website/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div id="hero">
{% include 'website/index-elements/hero.html' %}
</div><!-- /hero -->
</div>
</div>
{% endblock %}

{% block main %}
Expand Down
2 changes: 1 addition & 1 deletion app/workshop/templates/website/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ <h5 class="text-white h4">Digital Humanities Research Institute</h5>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggleExternalContent" aria-controls="navbarToggleExternalContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">DHRI Curriculum Website</a>
<a class="navbar-brand" href="/">DHRI Curriculum Website</a>
</div>
</nav>
34 changes: 0 additions & 34 deletions app/workshop/templates/workshop/___base.html

This file was deleted.

13 changes: 13 additions & 0 deletions app/workshop/templates/workshop/frontmatter-elements/hero.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ <h1>{{ workshop.name }}</h1>
<div class="lead mt-4">
{{ workshop.frontmatter.abstract | markdown | safe }}
</div>


{% if frontmatter.learning_objectives %}
<div class="my-5">
<hr class="pt-1" />
<h4>In this workshop, you will learn how to</h4>
{% for objective in frontmatter.learning_objectives.all %}
<li>{{ objective }}</li>
{% endfor %}
</div>
{% endif %}


<div class="d-flex align-items-end flex-column">
<a href="{% url 'workshop:frontmatter' workshop.slug %}lessons/1" type="button" class="btn btn-success btn-lg text-light">Get started</a>
<span class="align-text-bottom mt-2 text-muted small">This workshop is estimated to take {{ frontmatter.estimated_time }} hours to complete.</span>
Expand Down
10 changes: 5 additions & 5 deletions app/workshop/templates/workshop/frontmatter.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{% if frontmatter.prerequisites.count and frontmatter.resources.count %}
<div class="row pt-5">

<div class="col-12">
<div class="col-12 pb-2">
<h3>Before you start</h3>
<div class="lead mt-4">
Here is an introduction to the section "Before you start," and something about what it means.
Expand Down Expand Up @@ -51,8 +51,8 @@ <h4>Requirements</h4>
{% endif %}


<div class="row pt-5">
<div class="col-12">
<div class="row pt-5 rounded-sm">
<div class="col-12 pb-2">
<h3>Contexts</h3>
<div class="lead mt-4">
Here is an introduction to the section "Contexts," and something about what it means.
Expand All @@ -70,7 +70,7 @@ <h4>Ethical considerations</h4>

{% if frontmatter.readings.count %}
<div class="col-12 col-sm-4 mt-4 mt-md-2 overflow-hidden">
<h4>Readings</h4>
<h4>Readings before you get started</h4>
<hr />
<p style="font-size:1.05rem;">Here is an introductory paragraph about what the following readings are. It might contain <a href="">a link</a> to our "library" for the curriculum website, which can contain all kinds of information.</p>
{% for reading in frontmatter.readings.all %}
Expand All @@ -87,7 +87,7 @@ <h4>Readings</h4>

{% if frontmatter.projects.count %}
<div class="col-12 col-sm-4 mt-4 mt-md-2 overflow-hidden">
<h4>Project related to {{ workshop.name }}</h4>
<h4>Projects related to {{ workshop.name }}</h4>
<hr />
<p style="font-size:1.05rem;">Here is an introductory paragraph about what the following projects are and why they are listed here. It might contain <a href="">a link</a> to our "library" for the curriculum website, which can contain all kinds of information.</p>
{% for project in frontmatter.projects.all %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<div class="py-4">
<nav class="navbar navbar-expand-lg navbar-light bg-light" style="border-radius: 1rem !important;">
<a class="navbar-brand pr-4" href="#">{{ workshop.name }}</a>
<a class="navbar-brand pr-4" href="{% url 'workshop:frontmatter' slug=workshop.slug %}">{{ workshop.name }}</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
Expand Down Expand Up @@ -41,7 +41,7 @@
</li>
</ul>
<div>
<a href="{% url 'workshop:index' %}">&laquo; Back to all workshops</a>
<a href="{% url 'workshop:index' %}" type="button" class="btn btn-secondary">Back to Workshops</a>
</div>
</div>
</nav>
Expand Down
1 change: 1 addition & 0 deletions app/workshop/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.shortcuts import render, HttpResponse, get_object_or_404
from django.core.exceptions import MultipleObjectsReturned
from .models import Workshop
from website.models import Page


def _flexible_get(model=None, slug_or_int=''):
Expand Down

0 comments on commit ac788d5

Please sign in to comment.