This commit is contained in:
j 2013-02-12 13:06:07 +05:30
parent 15d3c2c3ba
commit edb0e391f5
5 changed files with 13 additions and 3 deletions

View file

@ -35,6 +35,11 @@ class Item(models.Model):
done = models.BooleanField(default=False)
def editable(self, user):
if user.is_anonymous():
return False
return user.is_staff or self.user == user
def get_overlay(self):
return json.dumps(self.overlay)

View file

@ -3,7 +3,7 @@
# GPL 2013
from __future__ import division, with_statement
import os
import json
from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404
from django.template import RequestContext
@ -88,10 +88,10 @@ def index(request):
def item(request, slug, edit=False):
item = get_object_or_404(models.Item, slug=slug)
edit = edit and item.editable()
edit = edit and item.editable(request.user)
context = RequestContext(request, {
'item': item,
'edit': edit
'edit': json.dumps(edit)
})
return render_to_response('item.html', context)

View file

@ -28,8 +28,11 @@ function getVideoOverlay(page) {
+ image.left + "px;";
div.appendChild(playButton(image.height/1.5));
div.onclick = function(event) {
event.preventDefault();
event.stopPropagation();
div.innerHTML = videoOverlay[page][id];
div.style.opacity = 1;
return false;
};
this.div.appendChild(div);
}

View file

@ -2716,6 +2716,7 @@ document.addEventListener('DOMContentLoaded', function webViewerLoad(evt) {
var file = params.file || DEFAULT_URL;
document.getElementById('openFile').setAttribute('hidden', 'true');
if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
document.getElementById('openFile').setAttribute('hidden', 'true');
} else {

View file

@ -33,6 +33,7 @@ limitations under the License.
<script type="text/javascript">
var DEFAULT_URL = '{{item.get_absolute_pdf_url}}';
var videoOverlay = {{item.get_overlay|safe}};
var edit = {{edit}};
</script>
<script type="text/javascript" src="/static/videoOverlay.js"></script>
<script type="text/javascript" src="/static/viewer.js"></script>