Skip to content

Commit

Permalink
Merge pull request #440 from ox-it/add-topic-list
Browse files Browse the repository at this point in the history
Add topic list
  • Loading branch information
ahaith committed Apr 29, 2016
2 parents f82ad14 + 4489aa2 commit 5542552
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
*.komodoproject

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -76,4 +74,6 @@ selenium-screenshot-*

.env

*.komodoproject

.DS_Store
3 changes: 2 additions & 1 deletion talks/events/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.conf.urls import patterns, url

from talks.events.views import (upcoming_events, show_person, show_event, events_for_day, show_department_organiser,
events_for_month, events_for_year, list_event_groups,show_event_group, show_topic,
events_for_month, events_for_year, list_event_groups,show_event_group, show_topic, list_topics,
show_department_descendant)
from talks.contributors.views import (create_person, edit_person, edit_event, create_event, create_event_group,
edit_event_group, delete_event, delete_event_group)
Expand All @@ -26,5 +26,6 @@
url(r'^series/id/(?P<event_group_slug>[^/]+)/edit$', edit_event_group, name='edit-event-group'),
url(r'^series/id/(?P<event_group_slug>[^/]+)/delete', delete_event_group, name='delete-event-group'),
url(r'^topics/id/$', show_topic, name="show-topic"),
url(r'^topics$', list_topics, name='browse-topics'),
url(r'^department/id/(?P<org_id>[^/]+)$', show_department_descendant, name="show-department"),
)
18 changes: 17 additions & 1 deletion talks/events/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.shortcuts import render, get_object_or_404, redirect
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger

from .models import Event, EventGroup, Person
from .models import Event, EventGroup, Person, TopicItem
from talks.events.models import ROLES_SPEAKER, ROLES_HOST, ROLES_ORGANISER
from talks.events.datasources import TOPICS_DATA_SOURCE, DEPARTMENT_DATA_SOURCE, DEPARTMENT_DESCENDANT_DATA_SOURCE
from talks.users.models import COLLECTION_ROLES_OWNER, COLLECTION_ROLES_EDITOR, COLLECTION_ROLES_READER
Expand Down Expand Up @@ -280,6 +280,22 @@ def show_topic(request):
else:
return render(request, 'events/topic.html', context)

def list_topics(request):
topics = TopicItem.objects.distinct()
topics_results = []

for topic in topics.all():
events = Event.published.filter(topics__uri=topic.uri)
if(len(events)>0):
api_topic = TOPICS_DATA_SOURCE.get_object_by_id(topic.uri)
if api_topic not in topics_results:
topics_results.append(api_topic)

context = {
'topics': topics_results,
}

return render(request, 'events/topic_list.html', context)

def show_department_organiser(request, org_id):
org = DEPARTMENT_DATA_SOURCE.get_object_by_id(org_id)
Expand Down
3 changes: 3 additions & 0 deletions talks/templates/events/navigation_for_listing.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@
<li>
<a href="{% url 'list-public-lists' %}">Talk Collections</a>
</li>
<li>
<a href="{% url 'browse-topics' %}">Topics</a>
</li>
</ul>
21 changes: 21 additions & 0 deletions talks/templates/events/topic_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% extends "base.html" %}

{% load staticfiles %}
{% load users %}

{% block title %}Public Collections{% endblock %}

{% block extrahead %}

{% endblock %}

{% block content %}

<ul class="list-group">

{% for topic in topics %}
<li class="list-group-item"><a href="{% url 'show-topic' %}?uri={{ topic.uri }}">{{ topic.prefLabel }}</a></li>
{% endfor %}
</ul>

{% endblock %}
2 changes: 0 additions & 2 deletions talks/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from talks.users.authentication import user_in_group_or_super
from .forms import CollectionForm


def webauth_logout(request):
context = {'was_webauth': True}
logout(request)
Expand Down Expand Up @@ -48,7 +47,6 @@ def browse_public_collections(request):

return render(request, 'users/collection_list.html', context)


def view_collection(request, collection_slug):
collection = Collection.objects.get(slug=collection_slug)
if collection.public:
Expand Down

0 comments on commit 5542552

Please sign in to comment.