diff --git a/RIGS/static/js/moment-twitter.js b/RIGS/static/js/moment-twitter.js new file mode 100644 index 00000000..ea05cd35 --- /dev/null +++ b/RIGS/static/js/moment-twitter.js @@ -0,0 +1,86 @@ +(function() { + var day, formats, hour, initialize, minute, second, week; + + second = 1e3; + + minute = 6e4; + + hour = 36e5; + + day = 864e5; + + week = 6048e5; + + formats = { + seconds: { + short: 's', + long: ' sec' + }, + minutes: { + short: 'm', + long: ' min' + }, + hours: { + short: 'h', + long: ' hr' + }, + days: { + short: 'd', + long: ' day' + } + }; + + initialize = function(moment) { + var twitterFormat; + twitterFormat = function(format) { + var diff, num, unit, unitStr; + diff = Math.abs(this.diff(moment())); + unit = null; + num = null; + if (diff <= second) { + unit = 'seconds'; + num = 1; + } else if (diff < minute) { + unit = 'seconds'; + } else if (diff < hour) { + unit = 'minutes'; + } else if (diff < day) { + unit = 'hours'; + } else if (format === 'short') { + if (diff < week) { + unit = 'days'; + } else { + return this.format('M/D/YY'); + } + } else { + return this.format('MMM D'); + } + if (!(num && unit)) { + num = moment.duration(diff)[unit](); + } + unitStr = unit = formats[unit][format]; + if (format === 'long' && num > 1) { + unitStr += 's'; + } + return num + unitStr; + }; + moment.fn.twitterLong = function() { + return twitterFormat.call(this, 'long'); + }; + moment.fn.twitter = moment.fn.twitterShort = function() { + return twitterFormat.call(this, 'short'); + }; + return moment; + }; + + if (typeof define === 'function' && define.amd) { + define('moment-twitter', ['moment'], function(moment) { + return this.moment = initialize(moment); + }); + } else if (typeof module !== 'undefined') { + module.exports = initialize(require('moment')); + } else if (typeof window !== "undefined" && window.moment) { + this.moment = initialize(this.moment); + } + +}).call(this); diff --git a/RIGS/templates/RIGS/activity_feed.html b/RIGS/templates/RIGS/activity_feed.html new file mode 100644 index 00000000..a69938e8 --- /dev/null +++ b/RIGS/templates/RIGS/activity_feed.html @@ -0,0 +1,110 @@ +{% extends request.is_ajax|yesno:"base_ajax_nomodal.html,base.html" %} + +{% load static %} +{% load paginator from filters %} +{% load to_class_name from filters %} + +{% block title %}Rigboard Activity Stream{% endblock %} + +{% block js %} + + + + + +{% endblock %} + +{% block content %} +{% if not request.is_ajax %} +
+
+
+

Rigboard Activity Stream

+
+
{% paginator %}
+
+ {% endif %} + + + + + +
+
+
+
+

Recent Changes

+
+ +
+ {% for version in object_list %} + {% if version.item_changes or version.field_changes or version.old == None %} +
+
+
+ + + +
+
+ {{version.revision.user.name}} + +
+ + {% if version.old == None %} + Created + {% else %} + Changed {% include 'RIGS/version_changes.html' %} in + {% endif %} + + + {% include 'RIGS/object_button.html' with object=version.current %} + +
+
+
+ {% endif %} + {% endfor %} +
+
+
+
+
+ + + + + {% if not request.is_ajax %} +
{% paginator %}
+
+ {% endif %} +{% endblock %} \ No newline at end of file diff --git a/RIGS/templates/RIGS/activity_stream.html b/RIGS/templates/RIGS/activity_table.html similarity index 79% rename from RIGS/templates/RIGS/activity_stream.html rename to RIGS/templates/RIGS/activity_table.html index 98ab963f..0259e264 100644 --- a/RIGS/templates/RIGS/activity_stream.html +++ b/RIGS/templates/RIGS/activity_table.html @@ -85,36 +85,4 @@
{% paginator %}
- - - - -
-
-

Rigboard Activity Stream - Scrollable Stream View
Possibly to go on homepage

-
-
-{% for version in object_list %} - {% if version.item_changes or version.field_changes or version.old == None %} -
- {% include 'RIGS/profile_button.html' with profile=version.revision.user %} - - {% if version.old == None %} - created - {% else %} - changed {% include 'RIGS/version_changes.html' %} in - {% endif %} - {% include 'RIGS/object_button.html' with object=version.current %} - -
- {% endif %} -{% endfor %} -
- -
- {% endblock %} \ No newline at end of file diff --git a/RIGS/templates/RIGS/index.html b/RIGS/templates/RIGS/index.html index ab87f449..49ac9554 100644 --- a/RIGS/templates/RIGS/index.html +++ b/RIGS/templates/RIGS/index.html @@ -1,46 +1,86 @@ {% extends 'base.html' %} {% block title %}RIGS{% endblock %} +{% block js %} + +{% endblock %} + {% block content %}
-

Rig Information Gathering System

+

Rig Information Gathering System

+
+
+

Welcome back, {{ user.get_full_name }}, there are {{ rig_count }} rigs coming up.

+

-
- {% if user.is_authenticated %} -

Welcome back {{ user.get_full_name }}.
- Your rigboard initials are {{ user.initials }}

- {% endif %} -

There are currently {{ rig_count }} rigs coming up.

- View Rigboard - - New Event - + +
+
+

Quick Links

+
+ + Rigboard + Calendar + + New Event + +
+ + TEC Forum + TEC Wiki + Price List + + +
+
+ +
+
+

Search Rigboard

+
+
+
+
+ + + + +
+
+
+
+
+
+ + + + +
+
+
+
+
+
+ + + + +
+
+
+
-
-
-
-

People

-
- - -
-
-
-

Organisations

-
- - -
-
-
-

Venues

-
- - -
-
-
+
+ +
{% endblock %} \ No newline at end of file diff --git a/RIGS/templates/RIGS/object_button.html b/RIGS/templates/RIGS/object_button.html index 9b5d838c..92d4ed5a 100644 --- a/RIGS/templates/RIGS/object_button.html +++ b/RIGS/templates/RIGS/object_button.html @@ -1,4 +1,4 @@ {% load to_class_name from filters %} {# pass in variable "object" to this template #} -{{object|to_class_name}} {{ object.pk|stringformat:"05d" }} \ No newline at end of file +{% if object.is_rig == False %}Non-rig{% elif object.dry_hire %}Dry Hire{% elif object.is_rig %}Rig{%else%}{{object|to_class_name}}{% endif %} | '{{object.name}}' \ No newline at end of file diff --git a/RIGS/urls.py b/RIGS/urls.py index 83804c80..05a0e170 100644 --- a/RIGS/urls.py +++ b/RIGS/urls.py @@ -93,9 +93,13 @@ urlpatterns = patterns('', permission_required_with_403('RIGS.view_event')(versioning.VersionHistory.as_view()), name='event_history', kwargs={'model': models.Event}), - url(r'^rigboard/activity$', - permission_required_with_403('RIGS.view_event')(versioning.ActivityStream.as_view()), - name='activity_stream'), + url(r'^rigboard/activity/$', + permission_required_with_403('RIGS.view_event')(versioning.ActivityTable.as_view()), + name='activity_table'), + + url(r'^rigboard/activity/feed/$', + permission_required_with_403('RIGS.view_event')(versioning.ActivityFeed.as_view()), + name='activity_feed'), # Finance url(r'^invoice/$', diff --git a/RIGS/versioning.py b/RIGS/versioning.py index eb5e80bc..43eec7ea 100644 --- a/RIGS/versioning.py +++ b/RIGS/versioning.py @@ -175,9 +175,9 @@ class VersionHistory(generic.ListView): return context -class ActivityStream(generic.ListView): +class ActivityTable(generic.ListView): model = reversion.revisions.Version - template_name = "RIGS/activity_stream.html" + template_name = "RIGS/activity_table.html" paginate_by = 25 def get_queryset(self): @@ -187,7 +187,31 @@ class ActivityStream(generic.ListView): def get_context_data(self, **kwargs): # Call the base implementation first to get a context - context = super(ActivityStream, self).get_context_data(**kwargs) + context = super(ActivityTable, self).get_context_data(**kwargs) + + items = [] + + for thisVersion in context['object_list']: + thisItem = get_changes_for_version(thisVersion, None) + items.append(thisItem) + + context ['object_list'] = items + + return context + +class ActivityFeed(generic.ListView): + model = reversion.revisions.Version + template_name = "RIGS/activity_feed.html" + paginate_by = 25 + + def get_queryset(self): + versions = get_versions_for_model([models.Event,models.Venue,models.Person,models.Organisation]) + return versions + + def get_context_data(self, **kwargs): + + # Call the base implementation first to get a context + context = super(ActivityFeed, self).get_context_data(**kwargs) items = [] diff --git a/templates/base_ajax_nomodal.html b/templates/base_ajax_nomodal.html new file mode 100644 index 00000000..aaaa06ed --- /dev/null +++ b/templates/base_ajax_nomodal.html @@ -0,0 +1,2 @@ +{% block js %}{% endblock %} +{% block content %}{% endblock %} \ No newline at end of file