Skip to content

Commit

Permalink
Merge pull request #458 from ox-it/cancelled_state_3475
Browse files Browse the repository at this point in the history
3488 and 3477 - Style changes to status description in event and even…
  • Loading branch information
markdoub committed May 5, 2016
2 parents d319001 + 678b8a5 commit d7c48e2
Show file tree
Hide file tree
Showing 14 changed files with 164 additions and 46 deletions.
7 changes: 5 additions & 2 deletions solr/talks/conf/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@

<field name="topics" type="text_en" indexed="true" stored="true" multiValued="true" />

<field name="published" type="boolean" indexed="true" stored="true" multiValued="false" />

<field name="suggestions" type="textSpell" indexed="true" stored="false" multiValued="true" omitTermFreqAndPositions="true" />

<field name="lists" type="text_en" indexed="true" stored="true" multiValued="true" />
Expand All @@ -166,6 +164,8 @@

<field name="group_exact" type="string" indexed="true" stored="true" multiValued="false" />

<field name="is_cancelled" type="boolean" indexed="true" stored="true" multiValued="false" />

<field name="lists_exact" type="string" indexed="true" stored="true" multiValued="true" />

<field name="slug" type="text_en" indexed="true" stored="true" multiValued="false" />
Expand All @@ -188,7 +188,10 @@

<field name="department" type="text_en" indexed="true" stored="true" multiValued="false" />

<field name="is_published" type="boolean" indexed="true" stored="true" multiValued="false" />


<!-- field to use to determine and enforce document uniqueness. -->
<uniqueKey>id</uniqueKey>
</schema>

30 changes: 29 additions & 1 deletion static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

.navbar-default .navbar-text {
color: #AAA;
}
}

.navbar-default .navbar-nav>.active>a, .navbar-default .navbar-nav>.active>a:hover, .navbar-default .navbar-nav>.active>a:focus {
color: #FFF;
Expand Down Expand Up @@ -225,6 +225,34 @@ div.share-this-links span {
color:black;
}

.cancelled
{
background-color: #b30000;
color: #fff;
}

.cancelled_teaser
{
color: #b30000;
}

.in_preparation
{
background-color: #f6d700;
color: #fff;
}

.in_preparation_teaser
{

color: #f6d700;
}

.list-group-item
{
background-color: #f5f5f5;
}

@media (max-width: 767px) {
#navbar-oxford-brandmark {
margin-right: 5px;
Expand Down
12 changes: 7 additions & 5 deletions talks/core/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,25 @@ def render(self, data, media_type=None, renderer_context=None):
def _event_to_ics(e):
event = Event()
event.add('summary', e['title_display'])

if 'description' in e:
print 'got a description'
desc_status = ""
desc_status = ""
if 'status' in e:
if e['status'] == 'preparation':
desc_status = '\nStatus: This talk is in preparation - details may change\n'

if e['status'] == 'cancelled':
desc_status = '\nStatus: This talk has been cancelled\n'

desc_with_speakers = e['description']
speakers_list = ""
if 'various_speakers' in e and e['various_speakers'] is True:
speakers_list = "\nSpeakers:\n Various"
elif 'speakers' in e:
if len(e['speakers']):
speakers_list = "\nSpeakers:\n" + ", ".join(get_speaker_name(speaker) for speaker in e['speakers'])
event.add('description', desc_status + desc_with_speakers + speakers_list)
event.add('description', desc_status + desc_with_speakers + speakers_list)

if 'start' in e:
event.add('dtstart', dt_string_to_object(e['start']))
if 'end' in e:
Expand Down
28 changes: 24 additions & 4 deletions talks/events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@

EVENT_PUBLISHED = 'published'
EVENT_IN_PREPARATION = 'preparation'
EVENT_CANCELLED = 'cancelled'
EVENT_STATUS_CHOICES = (
(EVENT_IN_PREPARATION, 'In preparation'),
(EVENT_PUBLISHED, 'Published'),
(EVENT_CANCELLED, 'Cancelled'), #RB 4/5/16 added cancelled state
)

class EventGroupManager(models.Manager):
Expand Down Expand Up @@ -108,7 +110,7 @@ def __unicode__(self):

def get_absolute_url(self):
return reverse('show-event-group', args=[self.slug])

def save(self, *args, **kwargs):
if not self.id and not self.slug:
# Newly created object, so set slug
Expand Down Expand Up @@ -408,11 +410,29 @@ def is_published(self):
return False
elif self.status == EVENT_IN_PREPARATION:
return False
elif self.status == EVENT_CANCELLED:
return False
elif self.status == EVENT_PUBLISHED:
return True
else:
return False

@property
def is_cancelled(self):
"""Check if the event has been cancelled (i.e. not embargo)
:return: True if the Event is cancelled else False
"""
if self.embargo:
return False
elif self.status == EVENT_IN_PREPARATION:
return False
elif self.status == EVENT_CANCELLED:
return True
elif self.status == EVENT_PUBLISHED:
return False
else:
return False

@property
def already_started(self):
if self.start <= timezone.now():
Expand Down Expand Up @@ -458,14 +478,14 @@ def public_collections_containing_this_event(self):

def get_audience_display(self):
# look up if it is one of the standard choices, else use the field value verbatim

audience_choices = dict(AUDIENCE_CHOICES)

try:
audience = audience_choices[self.audience]
except KeyError:
audience = self.audience

return audience

reversion.register(Event)
Expand Down
8 changes: 5 additions & 3 deletions talks/events/search_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class EventIndex(indexes.SearchIndex, indexes.Indexable):
department = indexes.CharField(faceted=True, null=True)
location = indexes.CharField(faceted=True, null=True)
topics = indexes.MultiValueField(faceted=True, null=True)
published = indexes.BooleanField(null=False)
is_published = indexes.BooleanField(null=False)
is_cancelled = indexes.BooleanField(null=False)
group = indexes.CharField(faceted=True, null=True)
group_slug = indexes.CharField(null=True)
lists = indexes.MultiValueField(faceted=True, null=True)
Expand Down Expand Up @@ -72,8 +73,9 @@ def prepare(self, obj):
self.prepared_data[self.topics.index_fieldname] = topics_pref_labels

# Published status
self.prepared_data[self.published.index_fieldname] = obj.is_published

self.prepared_data[self.is_published.index_fieldname] = obj.is_published
self.prepared_data[self.is_cancelled.index_fieldname] = obj.is_cancelled

# Series name
if obj.group:
self.prepared_data[self.group.index_fieldname] = obj.group.title
Expand Down
10 changes: 6 additions & 4 deletions talks/events/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,12 @@ def group_events (events):
minutes = ""
ampm = datetime.strftime(group_event.start, '%p')
group_event.display_time = str(int(hours))+minutes+ampm.lower()
comps = group_event.oxford_date.components
key = comps['day_name']+ " " +str(comps['day_number'])+ " " +comps['month_long']+ " "
key+= str(comps['year'])+ " ("+ str(comps['week']) + comps['ordinal']+ " Week, " +comps['term_long']+ " Term)"
if group_event.oxford_date:
comps = group_event.oxford_date.components
key = comps['day_name']+ " " +str(comps['day_number'])+ " " +comps['month_long']+ " "
key+= str(comps['year'])+ " ("+ str(comps['week']) + comps['ordinal']+ " Week, " +comps['term_long']+ " Term)"
else:
key = datetime.strftime(group_event.start, '%A, %d %B %Y')
if key not in grouped_events:
grouped_events[key] = []
event_dates.append(key)
Expand Down Expand Up @@ -294,7 +297,6 @@ def show_event_group(request, event_group_slug):
else:
return render(request, 'events/event-group.html', context)


def show_person(request, person_slug):
person = get_object_or_404(Person, slug=person_slug)

Expand Down
3 changes: 2 additions & 1 deletion talks/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li {% if '/user/lists' in request.path %} class="active" {% endif %}><a href="{{ manage_lists }}"><span class="glyphicon glyphicon-list-alt"></span> Manage Collections</a></li>
<li><a href="{% url 'logout' %}">Logout</a></li>
<li {% if '/user/mytalks' in request.path %} class="active" {% endif %}><a href="{% url 'my-talks' %}"><span class="glyphicon glyphicon-list-alt"></span> My Talks</a></li>
<li><a href="{% url 'logout' %}">Logout</a></li>
</ul>
</li>
{% else %}
Expand Down
16 changes: 14 additions & 2 deletions talks/templates/events/event.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@

{% if perms.events.change_event %}
<div class="container-fluid">
{% if event.get_status_display == 'Cancelled' %}
<div class="row bg-primary cancelled">
{% elif event.get_status_display == 'In preparation' %}
<div class="row bg-primary in_preparation">
{% else %}
<div class="row bg-primary">
{% endif %}
<div class="col-md-11"><h4>{{ event.get_status_display }}</h4></div>
<div class="col-md-1">
<strong>
Expand Down Expand Up @@ -92,7 +98,13 @@ <h3 class="panel-title contains-floating-buttons event">
<div class="in-preparation">
Status: This talk is in preparation - details may change
</div>
{% endif %}
{% endif %}
<!-- RB 4/5/16 added text to show when an event has been cancelled-->
{% if event.is_cancelled %}
<div class="cancelled">
Status: This talk has been cancelled
</div>
{% endif %}
{% endif %}


Expand Down Expand Up @@ -138,7 +150,7 @@ <h3 class="panel-title contains-floating-buttons event">
{% empty %}
<span>Speaker to be announced</span>
{% endfor %}

{% endif %}
{% endspaceless %}</li>
{% if event.api_organisation %}
Expand Down
33 changes: 19 additions & 14 deletions talks/templates/events/event.txt.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
{{ event.title_display }}
{% if not event.is_published %}
<br>Status: This talk is in preparation - details may change
{% endif %}
{% endif %}

<!-- RB 4/5/16 added text to show when an event has been cancelled-->
{% if event.is_cancelled %}
<br>Status: This talk has been cancelled
{% endif %}

{% if event.special_message %}
<br>{{ event.special_message }}
Expand All @@ -31,7 +36,7 @@
<br>Abstract not yet added
{% endif %}

<br>Date:
<br>Date:
{{ event.formatted_date}} ({{ event.oxford_date.formatted_nocal }})

<br>Venue:
Expand Down Expand Up @@ -60,55 +65,55 @@
{% endif %}

{% if event.organisers %}
<br>Organiser{{ organisers|pluralize }}:
<br>Organiser{{ organisers|pluralize }}:
{% for organiser in organisers %}
{{ organiser.name }}{% if organiser.bio %} ({{ organiser.bio }}){% endif %}{% if not forloop.last %}, {% endif %}
{% endfor %}
{% endfor %}
{% endif %}

{% if event.organiser_email %}
<br>Organiser contact email address:
{% if event.organiser_email %}
<br>Organiser contact email address:
{{event.organiser_email}}
{% endif %}

{% if event.hosts %}
<br>Host{{ hosts|pluralize }}:
<br>Host{{ hosts|pluralize }}:
{% for host in hosts %}
{{ host.name }}{% if host.bio %} ({{ host.bio }}){% endif %}{% if not forloop.last %}, {% endif %}
{% endfor %}
{% endif %}

{% if event.group %}
<br>Part of:
<br>Part of:
{{ event.group.title }}
{% endif %}

{% if event.topics.count %}
<br>Topics:
<br>Topics:
{% for topic in event.api_topics %}
{{ topic.prefLabel }}{% if not forloop.last %}, {% endif %}
{% endfor %}
{% endif %}

<br>Booking required?:
<br>Booking required?:
{{ event.get_booking_type_display }}

{% if event.booking_url %}
<br>Booking url:
<br>Booking url:
{{ event.booking_url }}
{% endif %}

{% if event.booking_email %}
<br>Booking email:
<br>Booking email:
{{ event.booking_email }}
{% endif %}

{% if event.cost %}
<br>Cost:
<br>Cost:
{{ event.cost }}
{% endif %}

<br>Audience:
<br>Audience:
{{ event.get_audience_display }}

{% if editors %}
Expand Down
14 changes: 8 additions & 6 deletions talks/templates/events/event_teaser.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
<!-- Display a single event teaser -->
<div class="event-teaser-wrapper">
<div class="event-teaser-text-wrapper">

<div class="pull-right">
<span style="padding-right: 20px">
{% if not is_search and not event.is_published %}<strong>Status</strong>: This talk is in preparation - details may change{% endif %}
</span>
{% if not is_search and perms.events.change_event %}
{% if request.user|can_edit_event:event %}
<a class="btn btn-default navbar-btn" href="{% url 'edit-event' event.slug %}">Edit</a>
Expand All @@ -30,11 +27,16 @@
</strong>

<a href="{% url 'show-event' event.slug %}" class="list-group-item-heading">
- <u>{{ event.title_display }}</u>
- <u>{% if event.title_display %}{{ event.title_display }}{% else %}{{ event.title }}{% endif %}</u>
</a>
{% if event.special_message %}
<br><span class="teaser-special-message">{{ event.special_message }}</span>
{% endif %}
{% if not event.is_published and not event.is_cancelled %}
<br /><span class='in_preparation_teaser'><strong>Status</strong>: This talk is in preparation - details may change</span>
{% elif event.is_cancelled %}
<br /><span class='cancelled_teaser'><strong>Status</strong>: This talk has been cancelled</span><!-- RB 4/5/16 added text to show when an event has been cancelled-->
{% endif %}
<br>
{% if event.various_speakers %}
Various Speakers
Expand All @@ -54,7 +56,7 @@
{% if event.group_slug %}
<!-- Search Results -->
<br>
Part of: <a href="{% url 'show-event-group' event.group_slug %}">event.group</a>
Part of: <a href="{% url 'show-event-group' event.group_slug %}">{{event.group}}</a>
{% else %}
{% if event.group %}
<br><a href="{{ event.group.get_absolute_url }}"><u>{{ event.group.title }}</u></a>
Expand Down

0 comments on commit d7c48e2

Please sign in to comment.