Skip to content

Commit

Permalink
Merge pull request #203 from ox-it/events-dashboard-199
Browse files Browse the repository at this point in the history
Events dashboard 199
  • Loading branch information
martinfilliau committed Jan 15, 2015
2 parents 6d91390 + 104d173 commit 89c169c
Show file tree
Hide file tree
Showing 12 changed files with 205 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
**********************
Events search endpoint
**********************
*************
Search Events
*************

Endpoint to search and retrieve information about events.

Expand Down
56 changes: 56 additions & 0 deletions docs/source/http_api/endpoints/event.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
**************
Retrieve event
**************

Endpoint to retrieve a specific event by id

All the responses conform to the `HAL specification <http://stateless.co/hal_specification.html>`_.

.. http:get:: /events/(string:id)
Retrieve event by ID

**Example request**:

.. sourcecode:: http

GET /api/events/example-event-id
Host: talks.ox.ac.uk
Accept: application/json

**Example response**:

.. sourcecode:: xml

<root>
<slug>complete-regeneration-of-skin</slug>
<url>/talks/id/complete-regeneration-of-skin/</url>
<title>Complete Regeneration of Skin</title>
<start>2015-01-30T23:00:00Z</start>
<end>2015-01-31T00:00:00Z</end>
<description>Skin</description>
<formatted_date>30 January 2015, 23:00</formatted_date>
<formatted_time>23:00</formatted_time>
<speakers>
<list-item>
<id>2</id>
<name>Professor Kazuo Kishi</name>
<bio>
Professor of Department of Reconstructive & Plastic Surgery, Keio University, Tokyo
</bio>
<title>
Professor Kazuo Kishi, Professor of Department of Reconstructive & Plastic Surgery, Keio University, Tokyo
</title>
</list-item>
</speakers>
<organisers/>
<hosts/>
<happening_today>False</happening_today>
<audience>oxonly</audience>

:param id: The unique slug identifier for the talk
:type id: string

:statuscode 200: Talk found
:statuscode 404: Talk not found
:statuscode 503: Service not available
66 changes: 66 additions & 0 deletions docs/source/http_api/endpoints/series.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
***************
Retrieve Series
***************

.. http:get:: /series/
Retrieve series by ID, including all talks

**Example request**:

.. sourcecode:: http

GET /api/series/series-id
Host: talks.ox.ac.uk
Accept: application/json

**Example response**

.. sourcecode:: xml
<root>
<id>1</id>
<title>A conference</title>
<description>A conference featuring a diverse array of groups</description>
<department_organiser/>
<events>
<list-item>
<slug>
deformation-and-melts-litosphere-astenosphere-boundary
</slug>
<url>
/talks/id/deformation-and-melts-litosphere-astenosphere-boundary/
</url>
<title>
Feedbacks between deformation and melts in the lithosphere-asthenosphere boundary
</title>
<start>2014-12-10T12:00:00Z</start>
<end>2014-12-10T14:00:00Z</end>
<description>Geo sciences</description>
<formatted_date>10 December 2014, 12:00</formatted_date>
<formatted_time>12:00</formatted_time>
<speakers>
<list-item>
<id>3</id>
<name>Dr Andrea Tommasi</name>
<bio>Geosciences Montpellier</bio>
<title>Dr Andrea Tommasi, Geosciences Montpellier</title>
</list-item>
</speakers>
<organisers/>
<hosts/>
<happening_today>False</happening_today>
<audience>oxonly</audience>
<api_location>...</api_location>
<api_organisation>...</api_organisation>
<api_topics>...</api_topics>
<class_name>Event</class_name>
</list-item>
</events>
</root>

:param id: The unique slug identifier for the series
:type id: string

:statuscode 200: Series found
:statuscode 404: Series not found
:statuscode 503: Service not available
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ HTTP API

http_api/*
http_api/endpoints/*
http_api/endpoints/Search/*

******************
Indices and tables
Expand Down
26 changes: 26 additions & 0 deletions static/css/events.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*These styles are used in the faceted navigation part of the dashboard pages*/
.filter-selected {
border-color: #b1cbe3;
border-style: solid;
border-width: 1px;
border-radius: 5px;
}

span.filter-active {
display: none;
}

.filter-selected>span {
display: inline;
float: right;
}

.nav>li>a.filter-absent {
display: none;
}

.nav>li>a.filter-exists {
font-size: smaller;
font-style: italic;
padding: 10px 0px 20px 30px;
}
2 changes: 1 addition & 1 deletion talks/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class EventViewSet(viewsets.ReadOnlyModelViewSet):


class EventGroupViewSet(viewsets.ReadOnlyModelViewSet):
renderer_classes = (ICalRenderer, JSONPRenderer, JSONPRenderer, XMLRenderer)
renderer_classes = (ICalRenderer, JSONRenderer, JSONPRenderer, XMLRenderer)
queryset = EventGroup.objects.all()
serializer_class = EventGroupWithEventsSerializer
lookup_field = 'slug'
Expand Down
25 changes: 22 additions & 3 deletions talks/events/templatetags/faceted_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ def facet_selected(context, **kwargs):
return kwargs.get('return_value', "filter-selected")
return ""

@register.simple_tag(takes_context=True)
def facet_has_selection(context, **kwargs):
"""
Returns the return_value as specified if the key is present in the query string with any value
"""
request = context['request']
param = kwargs['param']
query_String = request.META['QUERY_STRING']
if _parameter_present(query_String, param):
return kwargs.get('return_value', "filter-exists")
return "filter-absent"

def _set_parameter(query_string, key, value):
"""
Expand Down Expand Up @@ -90,11 +101,19 @@ def _remove_all_parameter(query_string, *args):
return '?%s' % '&'.join(parameters)


def _parameter_present(query_string, key, value):
def _parameter_present(query_string, key, value=None):
"""
Check whether the given key/value pair is present in the query string.
If the value is blank, it simply checks for the presence of the key
"""
already_there = False
if query_string:
for p in query_string.split('&'):
k, v = p.split('=')
if str(k) == str(key) and str(v) == str(value):
already_there = True
if str(k) == str(key):
if value:
if str(v) == str(value):
already_there = True
else:
already_there = True
return already_there
3 changes: 3 additions & 0 deletions talks/events/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,9 @@ def contributors_events(request):
elif events_missing == 'location':
args['missing'] = 'location'
events = events.filter(location='')
elif events_missing == 'speaker':
args['missing'] = 'speaker'
events = events.exclude(personevent__role=ROLES_SPEAKER)

events = events.order_by('start')
paginator = Paginator(events, count)
Expand Down
3 changes: 3 additions & 0 deletions talks/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}{% endblock %} - Oxford Talks</title>

<!-- Events custom stylesheet -->
<link rel="stylesheet" href="{% static 'css/events.css'%}">

<!-- Bootstrap -->
<link href="{% static "bootstrap/css/bootstrap.min.css"%}" rel="stylesheet">

Expand Down
41 changes: 18 additions & 23 deletions talks/templates/events/contributors_events.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,39 @@

{% block content %}

<style type="text/css">
.filter-selected {
background-color: #ddd;
}
</style>

<h2>Talks administration</h2>

<div class="container">
<div class="row">
<div class="col-xs-3">

<ul class="nav nav-list well">
<li><a href="{% url 'contributors-events' %}?date=future" class="filter-selected">Talks</a></li>
<li><a href="{% url 'contributors-eventgroups' %}">Series</a></li>
<li><a href="{% url 'contributors-persons' %}" class="">People</a></li>
<li><a href="{% url 'contributors-events' %}?date=future" class="filter-selected">Talks <span class="glyphicon glyphicon-ok filter-active"></span></a></li>
<li><a href="{% url 'contributors-eventgroups' %}">Series <span class="glyphicon glyphicon-ok filter-active"></span></a></li>
<li><a href="{% url 'contributors-persons' %}" class="">People <span class="glyphicon glyphicon-ok filter-active"></span></a></li>
</ul>

<strong>Filters</strong></li>
<ul class="nav nav-list well">

<li class="nav-header"><i class="icon-star"></i>Talk status</li>
<li><a href="{% facet_single_param status='published' %}" class="{% facet_selected status='published' %}">Published</a></li>
<li><a href="{% facet_single_param status='preparation' %}" class="{% facet_selected status='preparation' %}">In preparation</a></li>
<li><a href="{% facet_remove_all 'status' %}">All</a></li>
<li><a href="{% facet_single_param status='published' %}" class="{% facet_selected status='published' %}">Published <span class="glyphicon glyphicon-ok filter-active"></span></a>
</li>
<li><a href="{% facet_single_param status='preparation' %}" class="{% facet_selected status='preparation' %}">In preparation <span class="glyphicon glyphicon-ok filter-active"></span> </a></li>
<li><a href="{% facet_remove_all 'status' %}" class="{% facet_has_selection param='status' %}"><span class="glyphicon glyphicon-remove"></span>Remove Filter</a></li>

<li class="nav-header"><i class="icon-star"></i>Missing properties</li>
<li><a href="{% facet_single_param missing='title' %}" class="{% facet_selected missing='title' %}">Title TBA</a></li>
<li><a href="{% facet_single_param missing='location' %}" class="{% facet_selected missing='location' %}">Location</a></li>
<li><a href="{% facet_remove_all 'missing' %}">All</a></li>
<li class="nav-header"><i class="icon-star"></i>Missing Information</li>
<li><a href="{% facet_single_param missing='title' %}" class="{% facet_selected missing='title' %}">Untitled Talks <span class="glyphicon glyphicon-ok filter-active"></span></a></li>
<li><a href="{% facet_single_param missing='location' %}" class="{% facet_selected missing='location' %}">Venue <span class="glyphicon glyphicon-ok filter-active"></span></a></li>
<li><a href="{% facet_single_param missing='speaker' %}" class="{% facet_selected missing='speaker' %}">Speaker <span class="glyphicon glyphicon-ok filter-active"></span></a></li>
<li><a href="{% facet_remove_all 'missing' %}" class="{% facet_has_selection param='missing' %}"><span class="glyphicon glyphicon-remove"></span>Remove Filter</a></li>

<li class="nav-header"><i class="icon-time"></i>Date</li>
<li><a href="{% facet_single_param date='future' %}" class="{% facet_selected date='future' %}">Future events</a></li>
<li><a href="{% facet_single_param date='past' %}" class="{% facet_selected date='past' %}">Past events</a></li>
<li><a href="{% facet_remove_all 'date' %}">All</a></li>
<li><a href="{% facet_single_param date='future' %}" class="{% facet_selected date='future' %}">Future events <span class="glyphicon glyphicon-ok filter-active"></span></a></li>
<li><a href="{% facet_single_param date='past' %}" class="{% facet_selected date='past' %}">Past events <span class="glyphicon glyphicon-ok filter-active"></span></a></li>
<li><a href="{% facet_remove_all 'date' %}" class="{% facet_has_selection param='date' %}"><span class="glyphicon glyphicon-remove"></span>Remove Filter</a></li>

<li class="nav-headder"><i class="icon-star"></i>Show Editable Talks</li>
<li><a href="{% facet_single_param editable='true' %}" class="{% facet_selected editable='true' %}">Editable by me</a></li>
<li><a href="{% facet_remove_all 'editable' %}">All</a></li>
<li><a href="{% facet_single_param editable='true' %}" class="{% facet_selected editable='true' %}">Editable by me <span class="glyphicon glyphicon-ok filter-active"></span></a></li>
<li><a href="{% facet_remove_all 'editable' %}" class="{% facet_has_selection param='editable' %}"><span class="glyphicon glyphicon-remove"></span> Remove Filter</a></li>

</ul>
</div>
Expand Down
11 changes: 3 additions & 8 deletions talks/templates/events/contributors_groups.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@

{% block content %}

<style type="text/css">
.filter-selected {
background-color: #ddd;
}
</style>

<h2>Series administration</h2>

Expand All @@ -19,9 +14,9 @@ <h2>Series administration</h2>
<div class="col-xs-3">

<ul class="nav nav-list well">
<li><a href="{% url 'contributors-events' %}?date=future" class="">Talks</a></li>
<li><a href="{% url 'contributors-eventgroups' %}" class="filter-selected">Series</a></li>
<li><a href="{% url 'contributors-persons' %}" class="">People</a></li>
<li><a href="{% url 'contributors-events' %}?date=future" class="">Talks <span class="glyphicon glyphicon-ok filter-active"></span></a></li>
<li><a href="{% url 'contributors-eventgroups' %}" class="filter-selected">Series <span class="glyphicon glyphicon-ok filter-active"></span></a></li>
<li><a href="{% url 'contributors-persons' %}" class="">People <span class="glyphicon glyphicon-ok filter-active"></span></a></li>
</ul>
</div>

Expand Down
12 changes: 3 additions & 9 deletions talks/templates/events/contributors_persons.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,16 @@

{% block content %}

<style type="text/css">
.filter-selected {
background-color: #ddd;
}
</style>

<h2>People administration</h2>

<div class="container">
<div class="row">
<div class="col-xs-3">

<ul class="nav nav-list well">
<li><a href="{% url 'contributors-events' %}?date=future" class="">Talks</a></li>
<li><a href="{% url 'contributors-eventgroups' %}" class="">Series</a></li>
<li><a href="{% url 'contributors-persons' %}" class="filter-selected">People</a></li>
<li><a href="{% url 'contributors-events' %}?date=future" class="">Talks <span class="glyphicon glyphicon-ok filter-active"></span></a></li>
<li><a href="{% url 'contributors-eventgroups' %}" class="">Series <span class="glyphicon glyphicon-ok filter-active"></span></a></li>
<li><a href="{% url 'contributors-persons' %}" class="filter-selected">People <span class="glyphicon glyphicon-ok filter-active"></span></a></li>
</ul>
</div>

Expand Down

0 comments on commit 89c169c

Please sign in to comment.