mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +00:00
Redesigned homepage
This commit is contained in:
86
RIGS/static/js/moment-twitter.js
Normal file
86
RIGS/static/js/moment-twitter.js
Normal file
@@ -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);
|
||||||
110
RIGS/templates/RIGS/activity_feed.html
Normal file
110
RIGS/templates/RIGS/activity_feed.html
Normal file
@@ -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 %}
|
||||||
|
<script src="{% static "js/tooltip.js" %}"></script>
|
||||||
|
<script src="{% static "js/popover.js" %}"></script>
|
||||||
|
<script src="{% static "js/moment.min.js" %}"></script>
|
||||||
|
<script src="{% static "js/moment-twitter.js" %}"></script>
|
||||||
|
<script>
|
||||||
|
$(function () {
|
||||||
|
$('[data-toggle="popover"]').popover().click(function(){
|
||||||
|
if($(this).attr('href')){
|
||||||
|
window.location.href = $(this).attr('href');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// This keeps timeago values correct, but uses an insane amount of resources
|
||||||
|
// $(function () {
|
||||||
|
// setInterval(function() {
|
||||||
|
// $('.date').each(function (index, dateElem) {
|
||||||
|
// var $dateElem = $(dateElem);
|
||||||
|
// var formatted = moment($dateElem.attr('data-date')).fromNow();
|
||||||
|
// $dateElem.text(formatted);
|
||||||
|
// })
|
||||||
|
// });
|
||||||
|
// }, 10000);
|
||||||
|
moment().twitter();
|
||||||
|
|
||||||
|
$('.date').each(function (index, dateElem) {
|
||||||
|
var $dateElem = $(dateElem);
|
||||||
|
var formatted = moment($dateElem.attr('data-date'),"DD/MM/YYYY HH:mm").twitterLong();
|
||||||
|
$dateElem.text(formatted);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% if not request.is_ajax %}
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<h3>Rigboard Activity Stream</h3>
|
||||||
|
</div>
|
||||||
|
<div class="text-right col-sm-12">{% paginator %}</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12" style="overflow-y:scroll;">
|
||||||
|
<div class="list-group">
|
||||||
|
<div class="list-group-item" style="background-color: #eee;">
|
||||||
|
<h4 class="list-group-item-heading" style="margin:0;">Recent Changes</h4>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="max-height:514px; overflow:scroll;">
|
||||||
|
{% for version in object_list %}
|
||||||
|
{% if version.item_changes or version.field_changes or version.old == None %}
|
||||||
|
<div class="list-group-item" style="border-radius:0">
|
||||||
|
<div class="media" >
|
||||||
|
<div class="media-left">
|
||||||
|
<a href="#">
|
||||||
|
<img class="media-object" src="{{ version.revision.user.profile_picture}}" style="max-width:3em;">
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="media-body">
|
||||||
|
<b>{{version.revision.user.name}}</b>
|
||||||
|
<span class="pull-right"><small><span class="date" data-date="{{version.revision.date_created}}"></span></small></span>
|
||||||
|
<br>
|
||||||
|
<small>
|
||||||
|
{% if version.old == None %}
|
||||||
|
Created
|
||||||
|
{% else %}
|
||||||
|
Changed {% include 'RIGS/version_changes.html' %} in
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
{% include 'RIGS/object_button.html' with object=version.current %}
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
<div class="list-group-item" style="background-color: #eee;"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% if not request.is_ajax %}
|
||||||
|
<div class="align-right">{% paginator %}</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
@@ -85,36 +85,4 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="align-right">{% paginator %}</div>
|
<div class="align-right">{% paginator %}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<br>
|
|
||||||
<h2>Rigboard Activity Stream - Scrollable Stream View <br/><small>Possibly to go on homepage</small></h2>
|
|
||||||
<br>
|
|
||||||
<div style="
|
|
||||||
max-height: 500px;
|
|
||||||
max-width: 300px;
|
|
||||||
overflow-y:scroll;
|
|
||||||
border:1px solid black;">
|
|
||||||
{% for version in object_list %}
|
|
||||||
{% if version.item_changes or version.field_changes or version.old == None %}
|
|
||||||
<div class="well">
|
|
||||||
{% 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 %}
|
|
||||||
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -1,46 +1,86 @@
|
|||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
{% block title %}RIGS{% endblock %}
|
{% block title %}RIGS{% endblock %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
<script>
|
||||||
|
$(function () {
|
||||||
|
$( "#activity" ).load( "{% url 'activity_feed' %}", function() {
|
||||||
|
// Loaded
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
<h2>Rig Information Gathering System</h2>
|
<h1>R<small>ig</small> I<small>nformation</small> G<small>athering</small> S<small>ystem</small></h1>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<p><h4 class="list-group-item-heading" style="margin:0;">Welcome back, {{ user.get_full_name }}, there are {{ rig_count }} rigs coming up.</h4>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="well">
|
|
||||||
{% if user.is_authenticated %}
|
<div class="list-group">
|
||||||
<h3>Welcome back {{ user.get_full_name }}.<br />
|
<div class="list-group-item" style="background-color: #eee;">
|
||||||
<small>Your rigboard initials are {{ user.initials }}</small></h3>
|
<h4 class="list-group-item-heading" style="margin:0;">Quick Links</h4>
|
||||||
{% endif %}
|
</div>
|
||||||
<h3>There are currently {{ rig_count }} rigs coming up.</h3>
|
|
||||||
<a class="btn btn-default" href="{% url 'rigboard' %}">View Rigboard</a>
|
<a class="list-group-item" href="{% url 'rigboard' %}"><span class="glyphicon glyphicon-plus"></span> Rigboard</a>
|
||||||
<a class="btn btn-default" href="{% url 'event_create' %}">
|
<a class="list-group-item" href="{% url 'web_calendar' %}"><span class="glyphicon glyphicon-plus"></span> Calendar</a>
|
||||||
New Event <span class="glyphicon glyphicon-plus"></span>
|
<a class="list-group-item" href="{% url 'event_create' %}">
|
||||||
</a>
|
<span class="glyphicon glyphicon-plus"></span> New Event
|
||||||
|
</a>
|
||||||
|
<div class="list-group-item" style="background-color: #eee;"></div>
|
||||||
|
|
||||||
|
<a class="list-group-item" href="//members.nottinghamtec.co.uk/forum" target="_blank"><span class="glyphicon glyphicon-link"></span> TEC Forum</a>
|
||||||
|
<a class="list-group-item" href="//members.nottinghamtec.co.uk/wiki" target="_blank"><span class="glyphicon glyphicon-link"></span> TEC Wiki</a>
|
||||||
|
<a class="list-group-item" href="//members.nottinghamtec.co.uk/price" target="_blank"><span class="glyphicon glyphicon-link"></span> Price List</a>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="list-group-item" style="background-color: #eee;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="list-group">
|
||||||
|
<div class="list-group-item" style="background-color: #eee;">
|
||||||
|
<h4 class="list-group-item-heading" style="margin:0;">Search Rigboard</h4>
|
||||||
|
</div>
|
||||||
|
<div class="list-group-item">
|
||||||
|
<form class="form" role="form" action="{% url 'person_list' %}" method="GET">
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="search" name="q" class="form-control" placeholder="Search People" />
|
||||||
|
<span class="input-group-btn">
|
||||||
|
<button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search"></span></button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="list-group-item">
|
||||||
|
<form class="form" role="form" action="{% url 'organisation_list' %}" method="GET">
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="search" name="q" class="form-control" placeholder="Search Organisations" />
|
||||||
|
<span class="input-group-btn">
|
||||||
|
<button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search"></span></button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="list-group-item">
|
||||||
|
<form class="form" role="form" action="{% url 'venue_list' %}" method="GET">
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="search" name="q" class="form-control" placeholder="Search Venues" />
|
||||||
|
<span class="input-group-btn">
|
||||||
|
<button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search"></span></button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="list-group-item" style="background-color: #eee;"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6" id="activity">
|
||||||
<div class="well">
|
|
||||||
<div>
|
|
||||||
<h4><a href="{% url 'person_list' %}">People</a></h4>
|
|
||||||
<form class="form-inline" role="form" action="{% url 'person_list' %}" method="GET">
|
|
||||||
<input type="search" name="q" class="form-control" placeholder="Search People" />
|
|
||||||
<button type="submit" class="form-control"><span class="glyphicon glyphicon-search"></span></button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<h4><a href="{% url 'organisation_list' %}">Organisations</a></h4>
|
|
||||||
<form class="form-inline" role="form" action="{% url 'organisation_list' %}" method="GET">
|
|
||||||
<input type="search" name="q" class="form-control" placeholder="Search Organisations" />
|
|
||||||
<button type="submit" class="form-control"><span class="glyphicon glyphicon-search"></span></button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<h4><a href="{% url 'venue_list' %}">Venues</a></h4>
|
|
||||||
<form class="form-inline" role="form" action="{% url 'venue_list' %}" method="GET">
|
|
||||||
<input type="search" name="q" class="form-control" placeholder="Search Venues" />
|
|
||||||
<button type="submit" class="form-control"><span class="glyphicon glyphicon-search"></span></button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
{% load to_class_name from filters %}
|
{% load to_class_name from filters %}
|
||||||
{# pass in variable "object" to this template #}
|
{# pass in variable "object" to this template #}
|
||||||
|
|
||||||
<a title="{{object|to_class_name}} {{ object.pk|stringformat:"05d" }} | {{object.name}}" type="button" href="{{ object.get_absolute_url }}" class="btn btn-default btn-xs">{{object|to_class_name}} {{ object.pk|stringformat:"05d" }}</a>
|
<a title="{% 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}}'" href="{{ object.get_absolute_url }}">{% 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}}'</a>
|
||||||
10
RIGS/urls.py
10
RIGS/urls.py
@@ -93,9 +93,13 @@ urlpatterns = patterns('',
|
|||||||
permission_required_with_403('RIGS.view_event')(versioning.VersionHistory.as_view()),
|
permission_required_with_403('RIGS.view_event')(versioning.VersionHistory.as_view()),
|
||||||
name='event_history', kwargs={'model': models.Event}),
|
name='event_history', kwargs={'model': models.Event}),
|
||||||
|
|
||||||
url(r'^rigboard/activity$',
|
url(r'^rigboard/activity/$',
|
||||||
permission_required_with_403('RIGS.view_event')(versioning.ActivityStream.as_view()),
|
permission_required_with_403('RIGS.view_event')(versioning.ActivityTable.as_view()),
|
||||||
name='activity_stream'),
|
name='activity_table'),
|
||||||
|
|
||||||
|
url(r'^rigboard/activity/feed/$',
|
||||||
|
permission_required_with_403('RIGS.view_event')(versioning.ActivityFeed.as_view()),
|
||||||
|
name='activity_feed'),
|
||||||
|
|
||||||
# Finance
|
# Finance
|
||||||
url(r'^invoice/$',
|
url(r'^invoice/$',
|
||||||
|
|||||||
@@ -175,9 +175,9 @@ class VersionHistory(generic.ListView):
|
|||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
class ActivityStream(generic.ListView):
|
class ActivityTable(generic.ListView):
|
||||||
model = reversion.revisions.Version
|
model = reversion.revisions.Version
|
||||||
template_name = "RIGS/activity_stream.html"
|
template_name = "RIGS/activity_table.html"
|
||||||
paginate_by = 25
|
paginate_by = 25
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
@@ -187,7 +187,31 @@ class ActivityStream(generic.ListView):
|
|||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
|
|
||||||
# Call the base implementation first to get a context
|
# 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 = []
|
items = []
|
||||||
|
|
||||||
|
|||||||
2
templates/base_ajax_nomodal.html
Normal file
2
templates/base_ajax_nomodal.html
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
{% block js %}{% endblock %}
|
||||||
|
{% block content %}{% endblock %}
|
||||||
Reference in New Issue
Block a user