More work on other model support

This commit is contained in:
David Taylor
2015-05-23 16:49:54 +01:00
parent 6ab0715376
commit 3ed95d6687
7 changed files with 98 additions and 85 deletions

View File

@@ -71,7 +71,7 @@
<td>{{ version.revision.user.name }}</td>
<td>
{% if version.old == None %}
Event Created
Object Created
{% else %}
{% include 'RIGS/version_changes.html' %}
{% endif %} </td>
@@ -108,7 +108,7 @@
{% else %}
changed {% include 'RIGS/version_changes.html' %} in
{% endif %}
{% include 'RIGS/event_button.html' with event=version.current %}
{% include 'RIGS/object_button.html' with object=version.current %}
</div>
{% endif %}

View File

@@ -1,18 +0,0 @@
{# pass in variable "event" to this template #}
<button title="N{{ event.pk|stringformat:"05d" }} | {{event.name}}" type="button" href="{% url 'event_detail' event.pk %}" class="btn btn-default btn-xs" data-container="body" data-html="true" data-trigger='hover' data-toggle="popover" data-content='
<dl class="dl-vertical">
<dt>Date</dt>
<dd>{{event.start_date|date:"RIGS_DATE_FORMAT"}}</dd>
<dt>Status</dt>
<dd>{{event.get_status_display}}</dd>
<dt>MIC</dt>
<dd>{{event.mic.name}}</dd>
<dt>Venue</dt>
<dd>{{event.venue}}</dd>
</dl>
'>N{{ event.pk|stringformat:"05d" }}</button>

View File

@@ -1,52 +0,0 @@
{% extends request.is_ajax|yesno:"base_ajax.html,base.html" %}
{% load static %}
{% block title %}N{{ object.pk|stringformat:"05d" }} - Revision History{% endblock %}
{% block js %}
<script src="{% static "js/tooltip.js" %}"></script>
<script src="{% static "js/popover.js" %}"></script>
<script>
$(function () {
$('[data-toggle="popover"]').popover().click(function(){
if($(this).attr('href')){
window.location.href = $(this).attr('href');
}
});
})
</script>
{% endblock %}
{% block content %}
<h2>N{{ object.pk|stringformat:"05d" }} - Revision History </h2>
<br>
<table class="table table-striped">
<thead>
<tr>
<td>Version ID</td>
<td>Date</td>
<td>User</td>
<td>Changes</td>
</tr>
</thead>
<tbody>
{% for version in object_list %}
{% if version.item_changes or version.field_changes or version.old == None %}
<tr>
<td>{{ version.version.pk }}|{{ version.revision.pk }}</td>
<td>{{ version.revision.date_created|date:"RIGS_DATETIME_FORMAT" }}</td>
<td>{{ version.revision.user.name }}</td>
<td>
{% if version.old == None %}
Event Created
{% else %}
{% include 'RIGS/version_changes.html' %}
{% endif %}
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
{% endblock %}

View File

@@ -0,0 +1,4 @@
{% load to_class_name from filters %}
{# 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>

View File

@@ -0,0 +1,63 @@
{% extends request.is_ajax|yesno:"base_ajax.html,base.html" %}
{% load to_class_name from filters %}
{% load paginator from filters %}
{% load static %}
{% block title %}{{object|to_class_name}} {{ object.pk|stringformat:"05d" }} - Revision History{% endblock %}
{% block js %}
<script src="{% static "js/tooltip.js" %}"></script>
<script src="{% static "js/popover.js" %}"></script>
<script>
$(function () {
$('[data-toggle="popover"]').popover().click(function(){
if($(this).attr('href')){
window.location.href = $(this).attr('href');
}
});
})
</script>
{% endblock %}
{% block content %}
<div class="col-sm-12">
<div class="row">
<div class="col-sm-12">
<h3><a href="{{ object.get_absolute_url }}">{{object|to_class_name}} {{ object.pk|stringformat:"05d" }}</a> - Revision History</h3>
</div>
<div class="text-right col-sm-12">{% paginator %}</div>
</div>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<td>Date</td>
<td>Version ID</td>
<td>User</td>
<td>Changes</td>
</tr>
</thead>
<tbody>
{% for version in object_list %}
{% if version.item_changes or version.field_changes or version.old == None %}
<tr>
<td>{{ version.revision.date_created|date:"RIGS_DATETIME_FORMAT" }}</td>
<td>{{ version.version.pk }}|{{ version.revision.pk }}</td>
<td>{{ version.revision.user.name }}</td>
<td>
{% if version.old == None %}
Object Created
{% else %}
{% include 'RIGS/version_changes.html' %}
{% endif %}
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
<div class="align-right">{% paginator %}</div>
</div>
{% endblock %}

View File

@@ -1,6 +1,6 @@
from django.conf.urls import patterns, include, url
from django.contrib.auth.decorators import login_required
from RIGS import views, rigboard, finance, ical, versioning, forms
from RIGS import models, views, rigboard, finance, ical, versioning, forms
from django.views.generic import RedirectView
from PyRIGS.decorators import permission_required_with_403
@@ -25,6 +25,9 @@ urlpatterns = patterns('',
url(r'^people/(?P<pk>\d+)/$',
permission_required_with_403('RIGS.view_person')(views.PersonDetail.as_view()),
name='person_detail'),
url(r'^people/(?P<pk>\d+)/history/$',
permission_required_with_403('RIGS.view_person')(versioning.VersionHistory.as_view()),
name='person_history', kwargs={'model': models.Person}),
url(r'^people/(?P<pk>\d+)/edit/$',
permission_required_with_403('RIGS.change_person')(views.PersonUpdate.as_view()),
name='person_update'),
@@ -81,8 +84,8 @@ urlpatterns = patterns('',
name='event_archive'),
url(r'^event/(?P<pk>\d+)/history/$',
permission_required_with_403('RIGS.view_event')(versioning.EventRevisions.as_view()),
name='event_history'),
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()),

View File

@@ -139,14 +139,29 @@ def get_changes_for_version(newVersion, oldVersion=None):
return compare
class EventRevisions(generic.TemplateView):
class VersionHistory(generic.ListView):
model = reversion.revisions.Version
template_name = "RIGS/event_version_list.html"
template_name = "RIGS/version_history.html"
paginate_by = 25
def get_queryset(self, **kwargs):
thisModel = self.kwargs['model']
# thisObject = get_object_or_404(thisModel, pk=self.kwargs['pk'])
versions = reversion.get_for_object_reference(thisModel, self.kwargs['pk'])
return versions
def get_context_data(self, **kwargs):
thisEvent = get_object_or_404(models.Event, pk=self.kwargs['pk'])
versions = reversion.get_for_object(thisEvent)
thisModel = self.kwargs['model']
context = super(VersionHistory, self).get_context_data(**kwargs)
versions = context['object_list']
thisObject = get_object_or_404(thisModel, pk=self.kwargs['pk'])
items = []
for versionNo, thisVersion in enumerate(versions):
if versionNo >= len(versions)-1:
thisItem = get_changes_for_version(thisVersion, None)
@@ -155,11 +170,9 @@ class EventRevisions(generic.TemplateView):
items.append(thisItem)
context = {
'object_list': items,
'object': thisEvent
}
context['object_list'] = items
context['object'] = thisObject
return context
class ActivityStream(generic.ListView):