Skip to content

Commit

Permalink
Merge branch 'release/0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
JackMorganNZ committed May 18, 2018
2 parents 2155d41 + 3a0fd7f commit db0da91
Show file tree
Hide file tree
Showing 22 changed files with 442 additions and 183 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# Changelog

## 0.3.0 (Pre-release)

- Add milestone list and detail pages, with table showing milestone statuses. (fixes #9)
- Add basic searching for FAQ page. (fixes #26)
- Improve formatting of pīkau documentation.
- Fix typo in pīkau docs. (fixes #29)
- Change 'Pīkau' to 'pīkau'. (fixes #30)

## 0.2.0 (Pre-release)

- Readiness level is now optional. (fixes #24)
- Add tags to connect Pīkau to Self Review Tool (SRT). (fixes #21)
- Add tags to connect pīkau to Self Review Tool (SRT). (fixes #21)
- Explain website and pipeline with documentation. (fixes #14)
- Add link to Google Doc template. (fixes #13)
- Add contact page (further plans to add email form to page).
Expand Down
2 changes: 1 addition & 1 deletion config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Module for Django system configuration."""

__version__ = "0.2.0"
__version__ = "0.3.0"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Example Pīkau course
name: Example pīkau course
status: 6
overview: overview.md
language: en
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Reflection

Conclude and make any links to related Pīkau.
Conclude and make any links to related pīkau.

Each module needs to end with a fully referenced list citing all the resources that you have referred to during your writing. Use the APA 6th edition format for this.

Expand Down
2 changes: 1 addition & 1 deletion pikau/management/commands/loadpikau.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class Command(management.base.BaseCommand):
"""Required command class for the custom Django loadpikau command."""

help = "Loads Pīkau into the website"
help = "Loads pīkau into the website"

def handle(self, *args, **options):
"""Automatically called when the loadpikau command is given."""
Expand Down
10 changes: 5 additions & 5 deletions pikau/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ class Meta:

ordering = ["date", "name"]

@property
def is_upcoming(self):
"""Return true if milestone is in future."""
return self.date > date.today()

def __str__(self):
"""Text representation of Milestone object.
Expand Down Expand Up @@ -242,11 +247,6 @@ class PikauCourse(models.Model):
null=True,
)

@property
def is_upcoming_milestone(self):
"""Return true if milestone is in future."""
return self.milestone.date > date.today()

@property
def is_overdue_milestone(self):
"""Return true if not completed and past milestone."""
Expand Down
24 changes: 18 additions & 6 deletions pikau/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@
views.GlossaryList.as_view(),
name="glossary"
),
# eg: /pikau/pathways/
path(
"pathways/",
views.PathwaysView.as_view(),
name="pathways"
),
# eg: /pikau/goals/
path(
"goals/",
Expand All @@ -62,6 +56,24 @@
views.LevelDetail.as_view(),
name="level"
),
# eg: /pikau/milestones/
path(
"milestones/",
views.MilestoneList.as_view(),
name="milestone_list"
),
# eg: /pikau/milestones/1/
path(
"milestones/<int:pk>/",
views.MilestoneDetail.as_view(),
name="milestone"
),
# eg: /pikau/pathways/
path(
"pathways/",
views.PathwaysView.as_view(),
name="pathways"
),
# eg: /pikau/pikau-courses/
path(
"pikau-courses/",
Expand Down
45 changes: 45 additions & 0 deletions pikau/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Views for the pikau application."""

from re import sub
from django.views import generic
from django.db.models import F
from django.shortcuts import get_object_or_404
Expand All @@ -10,6 +11,7 @@
GlossaryTerm,
Goal,
Level,
Milestone,
PikauCourse,
PikauUnit,
ProgressOutcome,
Expand Down Expand Up @@ -82,6 +84,49 @@ class LevelDetail(LoginRequiredMixin, generic.DetailView):
model = Level


class MilestoneList(LoginRequiredMixin, generic.ListView):
"""View for the level list page."""

context_object_name = "milestones"

def get_queryset(self, **kwargs):
"""Get queryset of all milestones.
Returns:
Queryset of ordered Milestone objects.
"""
return Milestone.objects.order_by("date")

def get_context_data(self, **kwargs):
"""Provide the context data for the view.
Returns:
Dictionary of context data.
"""
context = super(MilestoneList, self).get_context_data(**kwargs)
line_broken_status_stages = []
for status_num, status_name in STATUS_CHOICES:
line_broken_status_stages.append(
(status_num, *sub(" - ", "\n", status_name.strip()).split(": "))
)
context["status_stages"] = line_broken_status_stages
for milestone in self.object_list:
milestone.status = {}
for status_num, status_name in STATUS_CHOICES:
milestone.status[status_num] = PikauCourse.objects.filter(
status=status_num,
milestone=milestone
).count()
return context


class MilestoneDetail(LoginRequiredMixin, generic.DetailView):
"""View for a level."""

context_object_name = "milestone"
model = Milestone


class PathwaysView(LoginRequiredMixin, generic.TemplateView):
"""View for the pikau pathway that renders from a template."""

Expand Down
64 changes: 64 additions & 0 deletions static/js/faq.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
var faq = [];
var fuze;
var faq_search_results;
var faq_all;

$(document).ready(function() {
faq_search_results = $('#faq-search-results');
faq_all = $('#faq-all');

// Load FAQ into array
load_faq();
// Create fuse search function
fuse = new Fuse(faq, {
shouldSort: true,
threshold: 0.6,
location: 0,
distance: 100,
maxPatternLength: 32,
minMatchCharLength: 1,
keys: [
'question',
'answer'
]
});
// // Change on each input
$('#faq-search').on('input', function(event){
display_results(event.target.value);
});
// // Call display function on load
display_results('');

$('#clear-search').click(function() {
$('#faq-search').val('');
display_results('');
});
});

function load_faq() {
$('#faq-all .faq').each(function() {
var item = {};
item.question = $('h5', this).text().trim();
item.answer = $('p', this).text().trim();
item.html = $(this).html();
faq.push(item);
});
}

function display_results(query) {
// Empty questions
faq_search_results.empty();

// If no query, show all QA's, otherwise filter by search
if (query.length == 0) {
faq_search_results.hide();
faq_all.show();

} else {
faq_all.hide();
faq_search_results.show();
$.each(fuse.search(query), function(i, item) {
faq_search_results.append($(item.html));
});
}
}
9 changes: 9 additions & 0 deletions static/js/fuse.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit db0da91

Please sign in to comment.