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) 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): def get_overlay(self):
return json.dumps(self.overlay) return json.dumps(self.overlay)

View file

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

View file

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

View file

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

View file

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