///if we are at home, the window location href corresponds to window location origin,\r
//so we select only links whose link points EXACTLY to the origin (home link)\r
var linkHref = normalize(this.href);\r
+ var elm = jQuery(this); //does not work with $.. conflicts?\r
if(pageOrigin===pageHref){\r
if(pageHref == linkHref){\r
- jQuery(this).addClass('active');\r
+ elm.addClass('active');\r
}else{\r
- jQuery(this).removeClass('active');\r
+ elm.removeClass('active');\r
}\r
}else{\r
//here, on the other hand, we select if a link points to a page or super page\r
//of the current paqge\r
if(linkHref!=pageOrigin && pageHref.match("^"+linkHref+".*")){\r
- jQuery(this).addClass('active');\r
+ elm.addClass('active');\r
}else{\r
- jQuery(this).removeClass('active');\r
+ elm.removeClass('active');\r
}\r
}\r
\r
initialize: function($super, cfg) {
$super();
+ //sets the fields required???? see ruler.js createPointer
this.configure(cfg, {
rulerLayout: [null, 'required'],
viewer: [null, 'required'],
zIndex: null,
className: [null, 'required'],
id: null,
- tooltip: null
+ tooltip: null,
+ canMove: false
});
this.cfg.rulerLayout = $J(this.cfg.rulerLayout);
this.cfg.viewer = $J(this.cfg.viewer);
this.width = this.cfg.viewer.width();
this.painter = new jsGraphics(this.cfg.viewer.get(0));
this._create();
- this._observeMouseEvents();
+ if(this.cfg.canMove){
+ this._observeMouseEvents();
+ }
},
free: function($super) {
labelPixelOffset = this.width - labelWidth;
this.label.css({
left: Math.round(labelPixelOffset) + 'px'
- });
+ });
this.position = pixelOffset;
}
return this;
if (this.mouseDown) {
var offset = (evt.pageX - this.cfg.rulerLayout.offset().left);
this.move(offset);
- this.fire('move', {
+ this.fire('move', { //calls move (see above)
offset: this.position,
finish: false
});
EDIT_MODE_SAVED:0,
EDIT_MODE_EDIT_TEXT:1,
EDIT_MODE_MARKER_MOVED:2,
+ //authentication ,sg
+ AUTHENTICATION_MSG :"You must be logged in and have the permission to edit/add/delete markers",
//function to retreve html elements in the edit div associated with marker:
getHtmElm: function(marker, elementName){
var div = this.divContainer;
var markerDiv;
if(div){
- var indexLabel, descriptionText, offsetLabel, closeButton, okButton, header, editButton, descriptionLabel;
+ var indexLabel, descriptionText, offsetLabel, deleteButton, okButton, header, editButton, descriptionLabel;
var margin = '1ex';
//index label
fontWeight:'bold',
display:'inline-block',
width:'3ex',
- textAlign: 'center'
- ,
+ textAlign: 'center',
fontFamily: 'monospace'
})
.html(insertionIndex+1);
})
//close button
- closeButton = $J('<a/>')
+ deleteButton = $J('<a/>')
.attr('title','delete marker')
.attr('name', this.MHE_DELETE_BUTTON)
.attr("href","#")
color:'white'
});
+ //var bRadius = '4px 4px 4px 4px';
//edit button
editButton = $J('<a/>')
.attr('title','edit marker description')
}))
.css({
float:'right',
- marginRight:margin
+ marginRight:margin,
});
+ // .append($J('<span/>').html("EDIT").css({
+ // fontSize:'70%',
+ // fontWeight:'bold',
+ // verticalAlign:'top',
+ // color:'#000000',
+ // textAlign:'center',
+ // margin:'0px',
+ // /*border:'1px solid red',*/
+ // position:'relative',
+ // top:'-0.6ex',
+ // padding:'0px'
+ // }))
+ // .css({
+ // float:'right',
+ // height:'1.7ex',
+ // marginRight:margin,
+ // border:'2px solid #333333',
+ // '-webkit-border-radius':bRadius,
+ // 'moz-border-radius': bRadius,
+ // 'border-radius': bRadius,
+ // paddingLeft:'10px',
+ // paddingRight:'10px',
+ // paddingTop:'0px',
+ // paddingBottom:'0px',
+ // backgroundColor:'#FFFFF0'
+ // });
//add all elements to header:
header = $J('<div/>')
.append(indexLabel)
.append(offsetLabel)
.append(descriptionLabel)
- .append(closeButton)
+ .append(deleteButton)
.append(editButton);
//description text
var editModeEditText = this.EDIT_MODE_EDIT_TEXT;
//action for edit
editButton.unbind('click').click( function(){
- func_fem.apply(klass,[marker,editModeEditText,editButton, descriptionText,
- descriptionLabel, okButton]);
+ if(CURRENT_USER_NAME){
+ func_fem.apply(klass,[marker,editModeEditText,editButton, descriptionText,
+ descriptionLabel, okButton]);
+ }else{
+ alert(klass.AUTHENTICATION_MSG);
+ }
return false; //avoid scrolling of the page on anchor click
});
var editModeSaved = this.EDIT_MODE_SAVED;
var func_send = this.sendHTTP;
okButton.unbind('click').click( function(){
- if(marker.desc !== descriptionText.val()){ //strict equality needed. See note below
- marker.desc = descriptionText.val();
- func_send(marker);
+ if(CURRENT_USER_NAME){
+ if(marker.desc !== descriptionText.val()){ //strict equality needed. See note below
+ marker.desc = descriptionText.val();
+ func_send(marker);
+ }
+ func_fem.apply(klass,[marker,editModeSaved,editButton, descriptionText,
+ descriptionLabel, okButton]);
+ }else{
+ alert(klass.AUTHENTICATION_MSG);
}
- func_fem.apply(klass,[marker,editModeSaved,editButton, descriptionText,
- descriptionLabel, okButton]);
return false; //avoid scrolling of the page on anchor click
});
var remove = this.remove;
//reference the class (this) as within the function below this will refer to the document
- closeButton.unbind('click').click( function(){
- remove.apply(klass,[marker]);
+ deleteButton.unbind('click').click( function(){
+ if(CURRENT_USER_NAME){
+ remove.apply(klass,[marker]);
+ }else{
+ alert(klass.AUTHENTICATION_MSG);
+ }
return false; //avoid scrolling of the page on anchor click
});
-
+
//insert the new div created
var divLen = div.children().length;
div.append(markerDiv);
//sets the edit mode in the div associated to marker. Last 4 arguments are optional
fireEditMode: function(marker, editMode, editButton, descriptionText,
- descriptionLabel, okButton){
+ descriptionLabel, okButton,deleteButton){
var e = this.getHtmElm;
if(editButton == undefined){
editButton = e(marker,this.MHE_EDIT_BUTTON);
if(okButton == undefined){
okButton = e(marker,this.MHE_OK_BUTTON);
}
+ if(deleteButton == undefined){
+ deleteButton = e(marker,this.MHE_DELETE_BUTTON);
+ }
var speed = 400; //fast is 200 slow is 600 (see jQuery help)
var klass = this;
+
+ //if user is not authenticated and does not have the necessary permission, we reset editmode to undefined
+ //we treat this case below (last else)
+ if(!(CURRENT_USER_NAME)){
+ editMode = undefined;
+ }
//var editModeSaved = this.EDIT_MODE_SAVED;
if(editMode == this.EDIT_MODE_EDIT_TEXT){ //edit text
descriptionLabel.hide(); //without arguments, otherwise alignement problems arise (in chrome)
//descriptionText.hide(speed);
okButton.show(speed);
}else{
- var function_sld = klass.setLabelDescription;
- editButton.show(speed, function(){
- function_sld.apply(klass,[marker]);
+ if(!(CURRENT_USER_NAME)){
+ editButton.hide();
+ deleteButton.hide();
descriptionLabel.show();
- });
+ }else{
+ var function_sld = klass.setLabelDescription;
+ editButton.show(speed, function(){
+ function_sld.apply(klass,[marker]);
+ descriptionLabel.show();
+ });
+ }
descriptionText.hide(speed);
okButton.hide(speed);
}
//sets the length of the label description. Note that all elements must be visible.
- //Therefore, we call $N.Util.setUpTabs() from controller once all markers have been loaded
+ //Therefore, we call $N.Util.setUpTabs() once all markers have been loaded
setLabelDescription: function(marker){
var mDiv = marker.div;
var e = this.getHtmElm;
var space = mDiv.width()-e(marker, this.MHE_INDEX_LABEL).outerWidth(true)-e(marker, this.MHE_OFFSET_LABEL).outerWidth(true)-
e(marker, this.MHE_EDIT_BUTTON).outerWidth(true)-e(marker, this.MHE_DELETE_BUTTON).outerWidth(true);
+ //space is the space available for the label. Decrease it of 20% in order to keep the extra space for
+ //zooming in. This does not assures indefinitely that we won't have overlaps or overflows but gives us
+ //some zoom increase without them. Note: css overflow property does not work
+ space = space - 0.1*space;
var labelDesc = e(marker, this.MHE_DESCRIPTION_LABEL);
var str='';
labelDesc.html(str);
this.waveContainer = this.cfg.viewer.find('.' + $N.cssPrefix + 'image-canvas');
this._setDuration(this.cfg.soundProvider.getDuration());
var imgContainer = this.cfg.viewer.find('.' + $N.cssPrefix + 'image-container'); // for IE
- this._observeMouseEvents(this.waveContainer.add(imgContainer));
- if (this.cfg.map) {
- this.cfg.map
- .observe('add', this.attach(this._onMapAdd))
- .observe('remove', this.attach(this._onMapRemove))
- .observe('indexchange', this.attach(this._onMapIndexChange));
- }
+
+ this._observeMouseEvents(this.waveContainer.add(imgContainer));
+ if (this.cfg.map) {
+ this.cfg.map
+ .observe('add', this.attach(this._onMapAdd))
+ .observe('remove', this.attach(this._onMapRemove))
+ .observe('indexchange', this.attach(this._onMapIndexChange));
+ }
+
this.cfg.soundProvider.observe('update', this.attach(this._onSoundProviderUpdate));
},
zIndex: 1000,
top:0,
className: 'pointer',
- tooltip: 'Move head'
+ tooltip: 'Move head',
+ canMove: true
});
-// //create the label
-// var tsMainLabel = $.find('.' + $N.cssPrefix + 'label');
-// if(tsMainLabel){
-// var label = tsMainLabel.find('#' + $N.cssPrefix + 'pointerOffset');
-// if(!label){
-// label = $("<span/>").id('#' + $N.cssPrefix + 'pointerOffset').css('zIndex','10').appendTo(tsMainLabel);
-// this.pointer.label = label;
-// }
-// }
+ // //create the label
+ // var tsMainLabel = $.find('.' + $N.cssPrefix + 'label');
+ // if(tsMainLabel){
+ // var label = tsMainLabel.find('#' + $N.cssPrefix + 'pointerOffset');
+ // if(!label){
+ // label = $("<span/>").id('#' + $N.cssPrefix + 'pointerOffset').css('zIndex','10').appendTo(tsMainLabel);
+ // this.pointer.label = label;
+ // }
+ // }
this.pointer
//.setText("+")
},
_onMouseUp: function(evt) {
+
if (this.mouseDown) {
this.mouseDown = false;
this.fire('move', {
},
_observeMouseEvents: function(element) {
+ if(!(CURRENT_USER_NAME)){
+ return;
+ }
element
.bind('click dragstart', function() {
return false;
fontSize: this.cfg.fontSize,
className: 'marker',
id: marker.id,
- tooltip: 'Move marker'
+ tooltip: 'Move marker',
+ canMove: CURRENT_USER_NAME
});
- m.observe('move', this.attach(this._onMarkerMove))
+ if(CURRENT_USER_NAME){
+ m.observe('move', this.attach(this._onMarkerMove))
+ }
+ //m.observe('move', this.attach(this._onMarkerMove))
+ m
.setText(index + 1)
.move(pixelOffset)
.show();
},
_onDoubleClick: function(evt) {
- if (this.cfg.map) {
+ if (this.cfg.map && CURRENT_USER_NAME) {
var offset = (evt.pageX - this.container.offset().left)
/ this.width * this.duration;
this.fire('markeradd', {
# Authors: Olivier Guilyardi <olivier@samalyse.com>
# David LIPSZYC <davidlipszyc@gmail.com>
+from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
from telemeta.models.core import *
from telemeta.models.enum import ContextKeyword
class Playlist(ModelCore):
"Item or collection playlist"
- owner_username = ForeignKey('User', related_name="playlists", db_column="owner_username")
+ #owner_username = ForeignKey('User', related_name="playlists", db_column="owner_username")
+ owner_username = ForeignKey(User, related_name="playlists", db_column="owner_username")
name = CharField(_('name'), required=True)
class Meta(MetaCore):
# Authors: Olivier Guilyardi <olivier@samalyse.com>
# David LIPSZYC <davidlipszyc@gmail.com>
+from django.contrib.auth.models import User
from telemeta.models.core import *
from django.core.exceptions import ObjectDoesNotExist
from django.utils.translation import ugettext_lazy as _
-class User(ModelCore):
- "Telemeta user"
- LEVEL_CHOICES = (('user', 'user'), ('maintainer', 'maintainer'), ('admin', 'admin'))
-
- username = CharField(_('username'), primary_key=True, max_length=64, required=True)
- level = CharField(_('level'), choices=LEVEL_CHOICES, max_length=32, required=True)
- first_name = CharField(_('first name'))
- last_name = CharField(_('last name'))
- phone = CharField(_('phone'))
- email = CharField(_('email'))
-
- class Meta(MetaCore):
- db_table = 'users'
-
- def __unicode__(self):
- return self.username
+#class User(ModelCore):
+# "Telemeta user"
+# LEVEL_CHOICES = (('user', 'user'), ('maintainer', 'maintainer'), ('admin', 'admin'))
+#
+# username = CharField(_('username'), primary_key=True, max_length=64, required=True)
+# level = CharField(_('level'), choices=LEVEL_CHOICES, max_length=32, required=True)
+# first_name = CharField(_('first name'))
+# last_name = CharField(_('last name'))
+# phone = CharField(_('phone'))
+# email = CharField(_('email'))
+#
+# class Meta(MetaCore):
+# db_table = 'users'
+#
+# def __unicode__(self):
+# return self.username
class Revision(ModelCore):
"Revision made by user"
element_id = IntegerField(_('element identifier'), required=True)
change_type = CharField(_('modification type'), choices=CHANGE_TYPE_CHOICES, max_length=16, required=True)
time = DateTimeField(_('time'), auto_now_add=True)
- user = ForeignKey('User', db_column='username', related_name="revisions", verbose_name=_('user'))
-
+ #user = ForeignKey('User', db_column='username', related_name="revisions", verbose_name=_('user'))
+ user = ForeignKey(User, db_column='username', related_name="revisions", verbose_name=_('user'))
+
@classmethod
def touch(cls, element, user):
"Create or update a revision"
soundManager.debugMode = false;
set_player_image_url('{% url telemeta-item-visualize item.public_id,visualizer_id,"WIDTH","HEIGHT" %}');
load_player({{ item.approx_duration.as_seconds }});
+
</script>
+<<<<<<< TREE
+
+{% if user.is_authenticated and perms.telemeta.change_mediaitem %}
+ <script type='text/javascript'>var CURRENT_USER_NAME="{{ user.username }}";</script>
+{% else %}
+ <script type='text/javascript'>var CURRENT_USER_NAME=undefined;</script>
+{% endif %}
+
+ {% endblock %}
+=======
{% endblock %}
+>>>>>>> MERGE-SOURCE
{% if item %}
{% block submenu %}
# Authors: Olivier Guilyardi <olivier@samalyse.com>
# David LIPSZYC <davidlipszyc@gmail.com>
+from django.contrib.auth.models import User
import unittest
from telemeta.models import *
from datetime import datetime, timedelta
def setUp(self):
"Create a test database based on objects created in Django"
- self.david = User.objects.create(username="david", level="user")
- self.olivier = User.objects.create(username="olivier", level="admin")
+# self.david = User.objects.create(username="david", level="user")
+# self.olivier = User.objects.create(username="olivier", level="admin")
+ self.david = User.objects.create_user(username="david")
+ self.olivier = User.objects.create_user(username="olivier")
self.country = LocationType.objects.create(code="country", name="Country")
self.continent = LocationType.objects.create(code="continent", name="Continent")