Merge with sub_roles

This commit is contained in:
chris2tof 2011-12-23 18:34:21 +08:00
parent fc591ee308
commit 62aaf79491
308 changed files with 2844 additions and 17841 deletions

1
.rspec
View File

@ -1 +1,2 @@
--colour --colour
--drb

1
.rvmrc
View File

@ -1 +0,0 @@
rvm use ruby-1.9.2-p290@orbit

View File

@ -10,13 +10,15 @@ gem 'mini_magick'
gem 'rubyzip' gem 'rubyzip'
gem 'sinatra' gem 'sinatra'
gem 'execjs' gem 'execjs'
gem 'mongoid' gem 'mongoid', :git => 'git://github.com/mongoid/mongoid.git', :ref => '7a915395db50e2bc6071a503a11530e644879e49'
gem 'rake' gem 'rake'
gem 'jquery-rails' gem 'jquery-rails'
gem 'sprockets' gem 'sprockets'
gem 'radius'
# For linux # For linux
gem 'therubyracer' gem 'therubyracer'
@ -33,6 +35,8 @@ end
gem 'ruby-debug19' gem 'ruby-debug19'
group :test, :development do group :test, :development do
gem 'spork'
gem 'database_cleaner' #Strategies for cleaning databases. Can be used to ensure a clean state for testing.
gem "rspec", "~> 2.0" gem "rspec", "~> 2.0"
gem "rspec-rails", "~> 2.0" gem "rspec-rails", "~> 2.0"
gem "factory_girl_rails" gem "factory_girl_rails"
@ -40,6 +44,7 @@ group :test, :development do
gem "rcov" gem "rcov"
gem "delorean" gem "delorean"
gem "watchr" gem "watchr"
gem "spork"
# gem "capybara" # gem "capybara"
# gem 'yard' # gem 'yard'
# gem "bluecloth" # gem "bluecloth"

View File

@ -1,3 +1,13 @@
GIT
remote: git://github.com/mongoid/mongoid.git
revision: 7a915395db50e2bc6071a503a11530e644879e49
ref: 7a915395db50e2bc6071a503a11530e644879e49
specs:
mongoid (2.4.0)
activemodel (~> 3.1)
mongo (~> 1.3)
tzinfo (~> 0.3.22)
GEM GEM
remote: http://rubygems.org/ remote: http://rubygems.org/
specs: specs:
@ -32,8 +42,9 @@ GEM
archive-tar-minitar (0.5.2) archive-tar-minitar (0.5.2)
arel (2.2.1) arel (2.2.1)
bcrypt-ruby (3.0.1) bcrypt-ruby (3.0.1)
bson (1.5.1) bson (1.5.2)
bson_ext (1.5.1) bson_ext (1.5.2)
bson (= 1.5.2)
builder (3.0.0) builder (3.0.0)
carrierwave (0.5.4) carrierwave (0.5.4)
activesupport (~> 3.0) activesupport (~> 3.0)
@ -49,6 +60,7 @@ GEM
execjs execjs
coffee-script-source (1.1.3) coffee-script-source (1.1.3)
columnize (0.3.5) columnize (0.3.5)
database_cleaner (0.7.0)
delorean (1.1.1) delorean (1.1.1)
chronic chronic
devise (1.5.2) devise (1.5.2)
@ -80,12 +92,8 @@ GEM
mime-types (1.17.2) mime-types (1.17.2)
mini_magick (3.3) mini_magick (3.3)
subexec (~> 0.1.0) subexec (~> 0.1.0)
mongo (1.5.1) mongo (1.5.2)
bson (= 1.5.1) bson (= 1.5.2)
mongoid (2.3.4)
activemodel (~> 3.1)
mongo (~> 1.3)
tzinfo (~> 0.3.22)
multi_json (1.0.4) multi_json (1.0.4)
orm_adapter (0.0.5) orm_adapter (0.0.5)
polyglot (0.3.3) polyglot (0.3.3)
@ -100,6 +108,7 @@ GEM
rack rack
rack-test (0.6.1) rack-test (0.6.1)
rack (>= 1.0) rack (>= 1.0)
radius (0.7.1)
rails (3.1.3) rails (3.1.3)
actionmailer (= 3.1.3) actionmailer (= 3.1.3)
actionpack (= 3.1.3) actionpack (= 3.1.3)
@ -154,6 +163,7 @@ GEM
rack (~> 1.3, >= 1.3.4) rack (~> 1.3, >= 1.3.4)
rack-protection (~> 1.1, >= 1.1.2) rack-protection (~> 1.1, >= 1.1.2)
tilt (~> 1.3, >= 1.3.3) tilt (~> 1.3, >= 1.3.3)
spork (0.8.5)
sprockets (2.0.3) sprockets (2.0.3)
hike (~> 1.2) hike (~> 1.2)
rack (~> 1.0) rack (~> 1.0)
@ -183,13 +193,15 @@ DEPENDENCIES
carrierwave (= 0.5.4) carrierwave (= 0.5.4)
ckeditor ckeditor
coffee-rails coffee-rails
database_cleaner
delorean delorean
devise devise
execjs execjs
factory_girl_rails factory_girl_rails
jquery-rails jquery-rails
mini_magick mini_magick
mongoid mongoid!
radius
rails rails
rake rake
rcov rcov
@ -200,6 +212,7 @@ DEPENDENCIES
sass-rails sass-rails
shoulda-matchers shoulda-matchers
sinatra sinatra
spork
sprockets sprockets
therubyracer therubyracer
uglifier uglifier

View File

@ -0,0 +1,25 @@
$('.attributes_block a.delete').live('click', function(){
$(this).parents('.list_item').remove();
});
$('.action a.remove_existing_record').live('click', function(){
$(this).next('.should_destroy').attr('value', 1);
$("#attribute_" + $(this).prev().attr('value')).hide();
});
$('.action a.switch').live('click', function(){
$(this).parent().toggleClass('disable');
var $am = $(this).next('.built_in_state')
$am.attr('value', ($am.attr('value') == "false") ? "true" : "false");
});
$('.select_type select').live('change', function(){
if(this.value == 'select')
{
$(this).next().show();
}
else
{
$(this).next().hide();
}
});

View File

@ -1,4 +1,21 @@
$("div.editable").live("mouseenter mouseleave", $("div.editable").live("mouseenter mouseleave", function (event) {
function (event) { $(this).children('.edit_link').toggle();
$(this).children('.edit_link').toggle(); });
});
$("#page_design_id").live('change', function() {
$.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_themes');
});
$("#page_module_app").live('change', function() {
var app_id = $(this).val();
if(app_id!=''){
$.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_frontend_pages',function(data, textStatus){
if(textStatus == 'success'){
$(this).after(data);
}
});
}
else{
$("#app_page_url").remove();
}
});

View File

@ -0,0 +1,513 @@
//Created by Harry Bomrah on Sep 21 2011
$rss = jQuery.noConflict();
var rcom={
//Pass dom and will return binded dom with starting year till current
insertDatePanel : function(dom,year){
if(!year)year=1901;
if(dom=="")return false;
domid=dom.attr("id");
var dt = new Date();
current_year=dt.getFullYear();
var dthtml="Year: <select name='"+domid+"_year'>";
for(i=current_year;i>=year;i--){
dthtml+="<option value='"+i+"'>"+i+"</option>";
}
dthtml+="</select> Date: <select name='"+domid+"_date'>";
for(i=1;i<=31;i++){
if(i<10)
dthtml+="<option value='0"+i+"'>"+i+"</option>";
else
dthtml+="<option value='"+i+"'>"+i+"</option>";
}
dthtml+="</select> Month: <select name='"+domid+"_month'>";
var months= Array("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
for(i=1;i<12;i++){
if(i<10)
dthtml+="<option value='0"+i+"'>"+months[i]+"</option>";
else
dthtml+="<option value='"+i+"'>"+months[i]+"</option>";
}
dthtml+="</select>";
dom.html(dthtml);
},
//loading overlay around a dom...
loadingWrapper : function(dom, display){
if(display){
dom.prepend("<div id='loading_wrapper' class='loading'></div>");
$rss("#loading_wrapper").height(dom.height());
$rss("#loading_wrapper").width(dom.width());
}else{
domId=dom.attr("id");
$rss("#"+domId+" #loading_wrapper").remove();
}
},
//validating a dom....
validate : function(dom, validation, errormsg){
var domValue = dom.val();
var error = false;
var regex="";
var msg = "";
switch(validation){
case "required":
if(domValue=="")error=true;
msg="Cannot be empty.";
break;
case "email":
regex=/^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
msg="Invalid Email Address.";
break;
case "number":
regex=/^\d*[0-9](|.\d*[0-9]|,\d*[0-9])?$/;
msg = "Only numbers are accepted.";
break;
case "alphanumeric":
regex=/^\s*[a-zA-Z0-9,\s]+\s*$/;
msg="Only numbers, alphabets and spaces are allowed.";
break;
}
domId=dom.attr("name");
if(errormsg=="")errormsg=msg;
if(regex!="")if(!regex.test(domValue))error=true;
if(error){$rss("#"+domId+"_error").remove();dom.after("<span id='"+domId+"_error' class='error'>"+errormsg+"</span>");return false;} else{ $rss("#"+domId+"_error").remove();return true;}
},
bindToSpinner : function(dom,data,callbackFn){
var domId = dom.attr("id");
var dhtml="";
var spinnerValue=Array();
var spinnerDisplay=Array();
$rss.each(data,function(i,it){
$rss.each(data[i],function(key,it){
spinnerValue.push(it);
});
});
dhtml="<select name='"+domId+"'>";
for(i=0,y=1,z=0;i<spinnerValue.length/2;i++,y+=2,z+=2){
dhtml+="<option value='"+spinnerValue[z]+"'>"+spinnerValue[y]+"</option>";
}
dhtml+="</select>";
dom.html(dhtml);
if(typeof callbackFn=="function")
callbackFn.call(this, dhtml);
},
//binds the recieved json to a table
bindToTable : function(dom,data,headers,actions,css_class,callbackFn){
if(!css_class)css_class="";
var dhtml="<table width='100%' cellpadding='5' cellspacing='5' class='"+css_class+"' ><thead><tr>";
var domId = dom.attr("id");
if(actions){
var btnTitles=Array();
var btnFunctions=Array();
$rss.each(actions,function(title,func){
btnTitles.push(title);
btnFunctions.push(func);
});
rcom.translate(btnTitles,function(convertedData){
btnTitles=convertedData.slice();
rcom.translate(headers,function(convertedData){
headers=convertedData;
if(!data)return;
$rss.each(headers,function(i,head){
dhtml+="<th>"+head+"</th>";
});
dhtml+="</thead></tr>";
if(data.length==0)dhtml+="<tr><td colspan='"+headers.length+"' align='center'>No Data</td></tr>";
$rss.each(data,function(i,item){
var cl="";
if(i%2!=0)cl="even";
dhtml+="<tr id='"+domId+"_"+item.id+"' class='"+cl+"'>";
$rss.each(item,function(i,it){
if(i!="id"){
if(it==null)it="Not Set";
dhtml+="<td align='center'>"+it+"</td>";
}
})
dhtml+="<td align='center'>";
for(x=0;x<btnTitles.length;x++){
dhtml+="<button onclick='"+btnFunctions[x]+"("+item.id+")'>"+btnTitles[x]+"</button>";
}
dhtml+="</td>";
dhtml+="</tr>";
});
dhtml+="</table>";
dom.html(dhtml);
});
});
}else{
rcom.translate(headers,function(convertedData){
headers=convertedData;
if(!data)return;
if(headers.length>0){
$rss.each(headers,function(i,head){
dhtml+="<th>"+head+"</th>";
});
}
dhtml+="</thead></tr>";
if(data.length==0)dhtml+="<tr><td colspan='"+headers.length+"' align='center'>No Data</td></tr>";
$rss.each(data,function(i,item){
var cl="";
if(i%2!=0)cl="even";
dhtml+="<tr id='"+domId+"_"+item.id+"' class='"+cl+"'>";
$rss.each(item,function(i,it){
if(i!="id"){
if(it==null)it="Not Set";
dhtml+="<td align='center'>"+it+"</td>";
}
})
dhtml+="</tr>";
});
dhtml+="</table>";
dom.html(dhtml);
});
}
if(typeof callbackFn=="function")
callbackFn.call(this, dhtml);
},
//convert to date string which can be directly inserted in database or according to any format.
convertToInsertableDate : function(y,m,d,format){
var dt="";
if(m<10)m="0"+m;
if(d<10)d="0"+d;
switch(format){
case "yyyy-mm-dd":
dt= y+"-"+m+"-"+d;
break;
case "dd-mm-yyyy":
dt= d+"-"+m+"-"+y;
break;
case "mm-dd-yyyy":
dt= m+"-"+d+"-"+y;
break;
default:
dt= y+"-"+m+"-"+d;
break;
}
return dt;
},
//a fucntion to show specific divs and hide all other
showDoms : function(doms){
$rss("body").find("div").each(function(){$rss(this).hide();});
$rss.each(doms,function(i,dom){
dom.show();
});
},
//a function to translate the word or array..
translate : function(data,callbackFn){
var cdata="";
var status =true;
if(!data){
if(typeof callbackFn=="function")
callbackFn.call(this,cdata);
status=false;
}
if(data==""){
if(typeof callbackFn=="function")
callbackFn.call(this,cdata);
status=false;
}
if(status){
$rss.getJSON("../../classes/translate.php", {fn:"translateThis",tData:data},function(convertedData){
if(typeof callbackFn=="function")
callbackFn.call(this, convertedData);
});
}
},
// a function to bind JSON to list
bindToList : function(dom,data,callbackFn){
var domId = dom.attr("id");
var dhtml="";
var listValue=Array();
var listDisplay=Array();
$rss.each(data,function(i,it){
$rss.each(data[i],function(key,it){
listValue.push(it);
});
});
dhtml="<ul id='"+domId+"_list'>";
for(i=0,y=1,z=0;i<listValue.length/2;i++,y+=2,z+=2){
dhtml+="<li id='li_"+listValue[z]+"'>"+listValue[y]+"</li>";
}
dhtml+="</ul>";
dom.html(dhtml);
if(typeof callbackFn=="function")
callbackFn.call(this,dhtml);
},
makeDraggable : function(handler,dom){
handler.css("position","absolute");
dom.css("position","absolute");
var puranix=0;
var nayeex=0;
var puraniy=0;
var nayeey=0;
var offset="";
var zIndex=dom.css("z-index");
handler.mousedown(function(e){
puranix=e.clientX;
puraniy=e.clientY;
offset=dom.offset();
$rss(this).mousemove(function(e){
nayeex=e.clientX-puranix;
nayeex+=offset.left;
nayeey=e.clientY-puraniy;
nayeey+=offset.top;
dom.css({"left":nayeex+"px","top":nayeey+"px","z-index":"9999"});
})
}).mouseup(function(){
$rss(this).unbind("mousemove");
dom.css("z-index",zIndex);
})
},
//automatically scrolls to the bottom of the div
scrollToBottom : function(dom){
var domId = dom.attr("id");
// var domScrollHeight = document.getElementById(domId).scrollHeight;
var obj = document.getElementById(domId);
if((obj.scrollTop+100) >= (obj.scrollHeight - obj.offsetHeight))
dom.scrollTop(obj.scrollHeight);
},
/*ajax loading of images... needs following settings
dom:in which images ve to be loaded
url:the server url for making ajax calls
limit:how many images to load
divClass:the class of div surrounding each image
nameClass:class for span showing name
fn:function to be called in on the server
imageSrc:the image source of all the images.
bindTo:to bind images to a onclick function or else will be binded to normal a tag.
urlKey:to specify the key of the value.. if bindTo is used, this will be neglected..
returns json;
*/
loadImages : function(settings,callbackFn){
var dom = settings.dom;
var domid= dom.attr("id");
var temp_array=Array();
var starting = $rss("#"+domid+" img:last").attr("id");
if(typeof starting != 'undefined'){
starting = starting.substr(4,starting.length-1);
}else{starting = 0};
var temp_var="";
var json = "";
var dhtml="";
var extraparam="";
if(typeof settings.extraParam != "undefined"){
extraparam = settings.extraParam;
}
$rss.getJSON(settings.url,{fn:settings.fn,id:settings.whereId,limit:settings.limit,start:starting,extra:extraparam},function(images){
json = eval(images);
$rss.each(images,function(i,pic){
var temp_array=Array();
var a_var=Array();
var name_var="";
var title="";
$rss.each(pic,function(i,value){
temp_array.push(value);
})
if(temp_array.length>=4){
name_var="<span class='"+settings.nameClass+"'>"+temp_array[3]+"</span></div>"
}
if(temp_array[2]==null)
title = "";
else
title = temp_array[2];
if(typeof settings.bindTo!="undefined"){
a_var[1]="onclick='"+settings.bindTo+"("+temp_array[0]+");return false;'";
a_var[0]="";
}else{a_var[0]='?'+settings.urlKey+'='+temp_array[0];a_var[1]="";}
dhtml="<div class='"+settings.divClass+"' id='img_holder_"+temp_array[0]+"' ><a href='"+a_var[0]+"' "+a_var[1]+" title='"+title+"'><img id='pic_"+temp_array[0]+"' style='display:none' src='"+settings.imageSrc+temp_array[1]+"' /></a>"+name_var;
dom.delay(100).append(dhtml);
$rss("#pic_"+pic.id).delay(100).fadeIn(200);
})
if(typeof callbackFn=="function")
callbackFn.call(this,json);
})
},
//function to get url variables...
getUrlVars : function(){
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++){
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
},
/*function to open a modalwindow on a page.. self reliant no images, no css needed.
settings
width:in percentage or pixcel
height:in percentage or pixcel
closeBtn:true or false
envClose:closing through background click, true or flase
loadDiv:load html from a div
loadPage:load a page
loadHtml: load html
*/
modalWindow : function(settings,callbackFn){
var envClose = settings.envClose;
var dhtml="";
if(typeof envClose == "undefined")
envClose = true;
var closeBtn = settings.closeBtn;
if(typeof closeBtn == "undefined")
closeBtn = true;
var rgmaskHeight = $rss(window).height();
var rgmaskWidth = $rss(window).width();
var tempheight = settings.height;
var tempwidth = settings.width;
if(typeof tempheight!="undefined"){
if(tempheight.charAt(tempheight.length-1)=='%')
tempheight=(rgmaskHeight*parseInt(tempheight.substr(0,tempheight.length)))/100;
}else{tempheight="auto";}
if(typeof tempwidth!="undefined"){
if(tempwidth.charAt(tempwidth.length-1)=='%')
tempwidth=(rgmaskWidth*parseInt(tempwidth.substr(0,tempwidth.length)))/100;
}else{tempwidth="auto";}
$rss("body").append('<div class="rgmask" id="rgsheath" style="height:'+rgmaskHeight+'px"></div>');
$rss("#rgsheath").css({background: "#000", width: "100%", position: "fixed", top: 0, left: 0,opacity:0.9,'z-index':199});
$rss("body").append('<div id="rgWindow"></div>');
$rss("#rgWindow").css({"position": "fixed", "z-index": "999", "background": "#fff", "border": "solid 3px #ccc", "padding": "20px", "overflow": "hidden", "border-radius": "12px", "-webkit-border-radius": "12px", "-moz-border-radius": "12px", "-ms-border-radius": "12px", "box-shadow": "0 0 20px rgba(0,0,0,0.9)","-webkit-box-shadow": "0 0 20px rgba(0,0,0,0.9)","-moz-box-shadow": "0 0 20px rgba(0,0,0,0.9)","-ms-box-shadow": "0 0 20px rgba(0,0,0,0.9)"});
var rgWTop = (rgmaskHeight-20)/2;
var rgWLeft = (rgmaskWidth-20)/2;
$rss("#rgWindow").css({top:rgWTop+"px", left:rgWLeft+"px"});
if(typeof settings.loadDiv!="undefined"){
dhtml = $rss("#"+settings.loadDiv).html();
$rss("#rgWindow").html(dhtml).hide();
prepareWindow();
}
if(typeof settings.loadHtml!="undefined"){
dhtml = settings.loadHtml;
$rss("#rgWindow").html(dhtml).hide();
prepareWindow();
}
if(typeof settings.loadPage!="undefined"){
$rss("#rgWindow").load(settings.loadPage,function(){$rss(this).hide();dhtml=$rss(this).html();prepareWindow();});
}
function prepareWindow(){
if(tempheight!="auto")
rgWTop = (rgmaskHeight-tempheight)/2;
else{
tempheight=$rss("#rgWindow").height();
rgWTop=(rgmaskHeight-tempheight)/2;
}
if(tempwidth!="auto")
rgWLeft = (rgmaskWidth-tempwidth)/2;
else{
tempwidth=$rss("#rgWindow").width();
rgWLeft=(rgmaskWidth-tempwidth)/2;
}
$rss("#rgWindow").empty().show();
var closebtn = "";
if(closeBtn)
closebtn='<a href="" style="display:block; width:28px; height:28px; line-height:28px; text-align:center; position:absolute; right:6px; top: 6px; font-family:Tahoma; font-weight:bold; border:solid 1px #ccc; border-radius: 15px;text-shadow:1px 1px 0 #fff; background:#f6f6f6; font-size:14px; text-decoration:none; color:#666" id="close_modal">X</a>';
$rss("#rgWindow").animate({"width":tempwidth+"px","height":tempheight+"px",top:rgWTop+"px", left:rgWLeft+"px"},500,function(){$rss("#rgWindow").html(closebtn+"<div id='rgContent' style='overflow:auto; overflow-x:none; height:"+tempheight+"px;'>"+dhtml+"</div>");
$rss("#close_modal").mouseover(function(){$rss(this).css("color","#999");}).mouseout(function(){$rss(this).css("color","#666");})
$rss("#close_modal").click(function(){
$rss("#rgWindow").empty();
var x = (rgmaskHeight-20)/2;
var y = (rgmaskWidth-20)/2;
$rss("#rgWindow").animate({top:x+"px", left:y+"px","width":"50px","height":"50px"},300,function(){$rss(this).fadeOut(100).remove();$rss("#rgsheath").fadeOut(500).remove();});
return false;
})
if(envClose)
$rss("#rgsheath").click(function(){
$rss("#rgWindow").empty();
var x = (rgmaskHeight-20)/2;
var y = (rgmaskWidth-20)/2;
$rss("#rgWindow").animate({top:x+"px", left:y+"px","width":"50px","height":"50px"},300,function(){$rss(this).fadeOut(100).remove();$rss("#rgsheath").fadeOut(500).remove();});})
if(typeof callbackFn=="function")
callbackFn.call(this,dhtml);
});
}
},
modalWindowClose : function(callbackFn){
if($rss("#rgWindow").length>0){
$rss("#rgWindow").empty();
var rgmaskHeight = $rss(window).height();
var rgmaskWidth = $rss(window).width();
var x = (rgmaskHeight-20)/2;
var y = (rgmaskWidth-20)/2
$rss("#rgWindow").animate({top:x+"px", left:y+"px","width":"50px","height":"50px"},300,function(){$rss(this).fadeOut(100).remove();$rss("#rgsheath").fadeOut(500).remove();})
}
if(typeof callbackFn=="function")
callbackFn.call(this,"harry");
},
bindDomToHead : function(dom){
var gc = dom.css("background");
var t = dom.offset();
var gw = dom.width();
$rss(window).scroll(function(){
var wt = $rss(window).scrollTop();
if ( wt > t.top ) {
var cssObj = {
'position':'fixed',
'top':0,
'width':gw,
'background':gc,
'box-shadow':'0 1px 0 rgba(0,0,0,0.2)',
'z-index':99
}
dom.css(cssObj);
} else {
dom.attr('style',"");
}
});
},
progressBar : function(dom,settings){
var domid = dom.prop("id");
if($rss("#rss_progressbar_div_"+domid).length==0){
if(typeof settings.top == "undefined")
settings.value = 1;
if(typeof settings.top == "undefined")
settings.top = (dom.height()-12)/2;
dom.append("<div id='rss_progressbar_div_"+domid+"' style='display:none;padding: 2px;background: #333;background: -webkit-linear-gradient(#111, #333);background: -moz-linear-gradient(#111, #333);background: -ms-linear-gradient(#111, #333);position: absolute;top: "+settings.top+"px;left: 50%;margin-left: -45%;width: 84%;box-shadow: inset 0 0 2px #000;border-radius: 4px;'><div id='rss_progressbar_"+domid+"' style='height: 8px; background: #36c;background: -webkit-linear-gradient(#7A98E7, #36c);background: -moz-linear-gradient(#7A98E7, #36c);background: -ms-linear-gradient(#7A98E7, #36c);border-radius: 2px; width: "+settings.value+"%;'></div></div>");
$rss("#rss_progressbar_div_"+domid).fadeIn(500);
}
},
progressBarValue : function(dom,value){
var domid = dom.prop("id");
if($rss("#rss_progressbar_div_"+domid).length==1){
$rss("#rss_progressbar_"+domid).animate({"width":value+"%"},100);
}
},
progressBarClose : function(dom){
var domid = dom.prop("id");
$rss("#rss_progressbar_div_"+domid).fadeOut(500,function(){$(this).remove();});
},
getInternetExplorerVersion: function(){
var rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer')
{
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
}
return rv;
}
}
$ = jQuery.noConflict();

View File

@ -6,4 +6,5 @@
// //
//= require jquery //= require jquery
//= require jquery_ujs //= require jquery_ujs
//= require page_edit
//= require side_bar_history //= require side_bar_history

View File

@ -1,10 +0,0 @@
var new_one = $('fieldset #new_one').clone();
$('fieldset #new_one').remove();
$('fieldset a.remove').live( "click", function(){
$(this).parent().remove();
});
$('fieldset a.add').click(function(){
new_one.clone().appendTo( $('fieldset') );
})

View File

@ -1,33 +0,0 @@
$('#attributes_block a.delete').live('click', function(){
$(this).parent().parent().parent().remove();
});
$('#attributes_block a.add').click(function(){
$('#attributes').append("<%= escape_javascript(render(:partial => 'admin/user_attribute_models/attribute_model', :object => @user_attribute_model.attribute_models.build)) %>");
});
$('#attributes_block a.remove_existing_record').click(function(){
$(this).next('.should_destroy').attr('value', 1);
$(this).parent().parent().hide();
});
$('#attributes_block a.change_built_in').click(function(){
$(this).parent().toggleClass('disable');
var $am = $(this).next('.built_in_state')
$am.attr('value', ($am.attr('value') == "false") ? "true" : "false");
});
$('.select_mulitlingual input').live('click', function(){
$(this).next().attr('value', this.checked);
});
$('.select_type select').live('change', function(){
if(this.value == 'select')
{
$(this).next().show();
}
else
{
$(this).next().hide();
}
});

View File

@ -1,6 +1,10 @@
$(document).ready(function(){ $(document).ready(function(){
$('#user_active_role').change(function(){ $('#user_role_id').change(function(){
$('#role_models .roles_block').hide(); $('#roles .attributes_block').hide();
$('#'+this.value+'_block').toggle(); $('#'+this.value+'_block').toggle();
}); });
$('.sub_role_select').change(function(){
$('#sub_role_' + this.value).toggle();
});
}); });

View File

@ -224,7 +224,7 @@ body{
.main_list ul { .main_list ul {
clear:both; clear:both;
} }
#porfile { #profile {
padding-top: 100px; padding-top: 100px;
} }
/*add_buttom*/ /*add_buttom*/

View File

@ -0,0 +1,17 @@
class Admin::AppAuthsController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :is_admin?
def index
@user_roles = UserRole.all.entries
apps = Purchase.where(:type =>"App")
@app_auth_data = apps.entries.map do |app|
app_c = eval(app.app_controller)
obj = app_c.new
obj_auth = obj.send "auth"
[:app_obj => app,:auth_field => obj_auth]
end
end
end

View File

@ -0,0 +1,63 @@
class Admin::InfosController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :is_admin?
before_filter :set_attribute, :only => [:index, :show, :new, :edit]
def index
@attributes = Info.all.entries
render :template => 'admin/attributes/index'
end
def show
end
def new
@attribute = Info.new
render :template => 'admin/attributes/new'
end
def edit
@attribute = Info.find(params[:id])
@i18n_variable = @attribute.i18n_variable
render :template => 'admin/attributes/edit'
end
def create
@attribute = Info.new(params[:info])
@attribute.save
redirect_to :action => :index
end
def update
@attribute = Info.find(params[:id])
@attribute.update_attributes(params[:info])
respond_to do |format|
format.html { redirect_to :action => :index }
format.js { render 'admin/attributes/toggle_enable' }
end
end
def destroy
@attribute = Info.find(params[:id])
@attribute.destroy
redirect_to :action => :index
end
def add_attribute_field
@attribute = Info.find(params[:id]) rescue nil
if !@attribute
@attribute = Info.new
end
end
protected
def set_attribute
@attribute_type = 'info'
@class = 'infos'
end
end

View File

@ -0,0 +1,9 @@
class Admin::ModuleAppsController < ApplicationController
def reload_frontend_pages
@module_app = ModuleApp.find(params[:id])
respond_to do |format|
format.js {}
end
end
end

View File

@ -19,6 +19,7 @@ class Admin::PagesController < ApplicationController
def new def new
@item = Page.new @item = Page.new
@apps = ModuleApp.all
@item.is_published = true @item.is_published = true
@item.parent_id = @parent_item.id rescue nil @item.parent_id = @parent_item.id rescue nil
@designs = Design.all.entries @designs = Design.all.entries
@ -27,6 +28,7 @@ class Admin::PagesController < ApplicationController
def edit def edit
@item = Page.find(params[:id]) @item = Page.find(params[:id])
@apps = ModuleApp.all
@i18n_variable = @item.i18n_variable @i18n_variable = @item.i18n_variable
@designs = Design.all.entries @designs = Design.all.entries
@design = @item.design @design = @item.design

View File

@ -0,0 +1,56 @@
class Admin::RolesController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :is_admin?
before_filter :set_attribute, :only => [:index, :show, :new, :edit]
def index
@attributes = Role.all.entries
render :template => 'admin/attributes/index'
end
def show
end
def new
@attribute = Role.new
render :template => 'admin/attributes/new'
end
def edit
@attribute = Role.find(params[:id])
@i18n_variable = @attribute.i18n_variable
render :template => 'admin/attributes/edit'
end
def create
@attribute = Role.new(params[:role])
@attribute.save
redirect_to :action => :index
end
def update
@attribute = Role.find(params[:id])
@attribute.update_attributes(params[:role])
respond_to do |format|
format.html { redirect_to :action => :index }
format.js { render 'admin/attributes/toggle_enable' }
end
end
def destroy
@attribute = Role.find(params[:id])
@attribute.destroy
redirect_to :action => :index
end
protected
def set_attribute
@attribute_type = 'role'
@class = 'roles'
end
end

View File

@ -68,11 +68,11 @@ class Admin::TranslationsController < ApplicationController
result << var if var.document_class.eql?('language') result << var if var.document_class.eql?('language')
result result
end end
@user_role_model_i18n_variables = @i18n_variables.inject([]) do |result, var| @role_i18n_variables = @i18n_variables.inject([]) do |result, var|
result << var if var.document_class.eql?('UserRoleModel') result << var if var.document_class.eql?('Role')
result result
end end
@user_info_model_i18n_variables = @i18n_variables.inject([]) do |result, var| @info_i18n_variables = @i18n_variables.inject([]) do |result, var|
result << var if var.document_class.eql?('UserInfoModel') result << var if var.document_class.eql?('UserInfoModel')
result result
end end

View File

@ -1,43 +0,0 @@
class Admin::UserAttributesController < ApplicationController
layout "admin"
before_filter :authenticate_user!
def index
@user_attributes = UserAttribute.all
end
def show
@user_attribute = UserAttribute.find(params[:id])
end
def new
@user_attribute = UserAttribute.new
end
def edit
@user_attribute = UserAttribute.find(params[:id])
end
def create
@user_attribute = UserAttribute.new(params[:user_attribute])
@user_attribute.save
redirect_to :action => :index
end
def update
@user_attribute = UserAttribute.find(params[:id])
@user_attribute.update_attributes(params[:user_attribute])
redirect_to :action => :index
end
def destroy
@user_attribute = UserAttribute.find(params[:id])
@user_attribute.destroy
redirect_to :action => :index
end
end

View File

@ -1,59 +0,0 @@
class Admin::UserInfoModelsController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :is_admin?
before_filter :set_attribute, :only => [:index, :show, :new, :edit]
def index
@user_attribute_models = UserInfoModel.all.entries
render :template => 'admin/user_attribute_models/index'
end
def show
#@user_attribute_model = UserInfoModel.find(params[:id])
end
def new
@user_attribute_model = UserInfoModel.new
render :template => 'admin/user_attribute_models/new'
end
def edit
@user_attribute_model = UserInfoModel.find(params[:id])
@i18n_variable = @user_attribute_model.i18n_variable
render :template => 'admin/user_attribute_models/edit'
end
def create
@user_attribute_model = UserInfoModel.new(params[:user_info_model])
@user_attribute_model.save
redirect_to :action => :index
end
def update
@user_attribute_model = UserInfoModel.find(params[:id])
@user_attribute_model.update_attributes(params[:user_info_model])
respond_to do |format|
format.html { redirect_to :action => :index }
format.js { render 'admin/user_attribute_models/toggle_enable' }
end
end
def destroy
@user_attribute_model = UserInfoModel.find(params[:id])
@user_attribute_model.destroy
@user_attribute_model.destroy_i18n_variables
redirect_to :action => :index
end
protected
def set_attribute
@attribute = 'info'
@class = 'infos'
end
end

View File

@ -1,60 +0,0 @@
class Admin::UserRoleModelsController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :is_admin?
before_filter :set_attribute, :only => [:index, :show, :new, :edit]
def index
@user_attribute_models = UserRoleModel.all.entries
render :template => 'admin/user_attribute_models/index'
end
def show
#@user_attribute_model = UserRoleModel.find(params[:id])
end
def new
@user_attribute_model = UserRoleModel.new
render :template => 'admin/user_attribute_models/new'
end
def edit
@user_attribute_model = UserRoleModel.find(params[:id])
@i18n_variable = @user_attribute_model.i18n_variable
render :template => 'admin/user_attribute_models/edit'
end
def create
@user_attribute_model = UserRoleModel.new(params[:user_role_model])
@user_attribute_model.save
redirect_to :action => :index
end
def update
@user_attribute_model = UserRoleModel.find(params[:id])
@user_attribute_model.update_attributes(params[:user_role_model])
respond_to do |format|
format.html { redirect_to :action => :index }
format.js { render 'admin/user_attribute_models/toggle_enable' }
end
end
def destroy
@user_attribute_model = UserRoleModel.find(params[:id])
@user_attribute_model.destroy
@user_attribute_model.destroy_i18n_variables
redirect_to :action => :index
end
protected
def set_attribute
@attribute = 'role'
@class = 'roles'
end
end

View File

@ -10,25 +10,18 @@ class Admin::UsersController < ApplicationController
def show def show
@user = User.find(params[:id]) @user = User.find(params[:id])
get_info_role_models get_info_and_roles
end end
def new def new
@user = User.new @user = User.new
get_info_role_models get_info_and_roles
end end
def create def create
puts params.to_yaml
@user = User.new(params[:user]) @user = User.new(params[:user])
if @user.save if @user.save
@user.user_infos.each do |user_info|
user_info.save
user_info.attribute_values.each(&:save)
end
@user.user_roles.each do |user_role|
user_role.save
user_role.attribute_values.each(&:save)
end
flash[:notice] = t('admin.create_success_user') flash[:notice] = t('admin.create_success_user')
redirect_to :action => :index redirect_to :action => :index
else else
@ -38,7 +31,7 @@ class Admin::UsersController < ApplicationController
def edit def edit
@user = User.find(params[:id]) @user = User.find(params[:id])
get_info_role_models get_info_and_roles
end end
def update def update
@ -55,7 +48,7 @@ class Admin::UsersController < ApplicationController
flash[:notice] = t('admin.update_success_user') flash[:notice] = t('admin.update_success_user')
redirect_to :action => :index redirect_to :action => :index
else else
get_info_role_models get_info_and_roles
render :action => :edit render :action => :edit
end end
end end
@ -66,10 +59,6 @@ class Admin::UsersController < ApplicationController
else else
@user = User.find(params[:id]) @user = User.find(params[:id])
@user.destroy @user.destroy
@user.user_attributes.each do |ua|
ua.attribute_values.each(&:destroy)
ua.destroy
end
end end
redirect_to :action => :index redirect_to :action => :index
@ -77,11 +66,11 @@ class Admin::UsersController < ApplicationController
protected protected
def get_info_role_models def get_info_and_roles
@user_info_models = UserInfoModel.excludes('disabled' => true) @infos = Info.excludes('disabled' => true)
@user_role_models = UserRoleModel.excludes('disabled' => true) @roles = Role.excludes('disabled' => true)
end end
def set_attribute def set_attribute
@class = 'users' @class = 'users'
end end

View File

@ -1,7 +1,7 @@
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
protect_from_forgery protect_from_forgery
include Parser include ParserFrontEnd, ParserBackEnd
helper :all helper :all
before_filter :set_locale, :set_site before_filter :set_locale, :set_site
@ -36,9 +36,9 @@ class ApplicationController < ActionController::Base
end end
# Render the page # Render the page
def render_page def render_page(url = nil)
if @item if @item
render :text => parse_page(@item) render :text => parse_page(@item,url)
else else
render :text => '404 Not Found' render :text => '404 Not Found'
end end

View File

@ -9,19 +9,28 @@ class PagesController < ApplicationController
end end
end end
def show def appfront
begin
item = Item.first(:conditions => {:full_name => params[:page_name]}) pre_uri = URI.split request.env['HTTP_REFERER']
case item._type pre_item_fullname = pre_uri[5][1..-1]
when 'Page' @item = Item.first(:conditions => {:full_name => pre_item_fullname})
@item = item redirect_to (request.env['HTTP_REFERER'].partition("?")[0]+"?app_url=#{request.fullpath}")
render_page
when 'Link'
redirect_to "http://#{item[:url]}"
end
rescue
render :file => "#{Rails.root}/public/404.html", :status => :not_found
end
end end
def show
begin
item = Item.first(:conditions => {:full_name => params[:page_name]})
case item._type
when 'Page'
@item = item
render_page ((params[:app_url]+'?inner='+"true" if params[:app_url]))
when 'Link'
redirect_to "http://#{item[:url]}"
end
rescue
render :file => "#{Rails.root}/public/404.html", :status => :not_found
end
end
end end

View File

@ -1,7 +1,7 @@
module Admin::UserHelper module Admin::UserHelper
def show_user_attribute(object, key, locale = '') def show_attribute(object, field_id, locale = '')
attribute = object.attribute_values.detect {|av| av.key.to_s.eql?(key.to_s) || av[locale.to_s].eql?(locale.to_s) } rescue nil attribute = object.attribute_values.detect {|av| av.attribute_field_id.eql?(field_id) || av[locale.to_s].eql?(locale.to_s) } rescue nil
if attribute if attribute
if locale.to_s.blank? if locale.to_s.blank?
attribute['key'] attribute['key']

View File

@ -48,5 +48,12 @@ module ApplicationHelper
message % item message % item
end end
end end
def add_attribute(partial, f, attribute)
new_object = f.object.send(attribute).build
fields = f.fields_for(attribute, new_object, :child_index => "new_#{attribute}") do |f|
render :partial => partial, :object => new_object, :locals => {:f => f}
end
end
end end

77
app/models/app_auth.rb Normal file
View File

@ -0,0 +1,77 @@
class AppAuth
include Mongoid::Document
include Mongoid::Timestamps
# after_save :update_block_list,:update_privilage_list
field :title
field :token
field :all ,type: Boolean,default: false
belongs_to :module_app
belongs_to :users
# belongs_to :users,as: :block_users, :inverse_of => :privilege_apps
has_and_belongs_to_many :blocked_users, :inverse_of => nil, :class_name => "User"
has_and_belongs_to_many :privilege_users, :inverse_of => nil, :class_name => "User"
has_and_belongs_to_many :roles
def add_user_to_black_list user
unless self.blocked_users.include?(user)
self.blocked_users << user
self.save!
else
false #should put error message for user existed in list already
end
end
def remove_user_from_black_list user
if self.blocked_users.include? user
self.blocked_users.delete user
self.save!
else
false #should put error message for user not existed in list
end
end
def add_user_to_privilege_list user
unless self.privilege_users.include? user
self.privilege_users << user
self.save!
else
false #should put error message for user existed in list already
end
end
def remove_user_from_privilege_list user
if self.privilege_users.include? user
self.privilege_users.delete user
self.save!
else
false #should put error message for user not existed in list
end
end
def auth_users
if self.all?
User.all.entries
else
ary= self.roles.collect do |role|
role.users
end
ary << self.privilege_users
ary.flatten!
end
end
def auth_users_after_block_list
auth_users - self.blocked_users
end
# protected
end

View File

@ -24,6 +24,35 @@ class Design
after_save :procs_embedded_objects after_save :procs_embedded_objects
# after_destroy :del_embedded_objects # after_destroy :del_embedded_objects
# validate do
# errors.add('atttribute1', 'error for 1') if files_with_duplicate?
# errors.add('atttribute2', 'error for 1') if files_with_noname?
# end
def files_with_duplicate?
[self.javascripts, self.images,self.themes].each do |objects_hash|
ary = objects_hash.collect{ |k| k.file_filename}
ary.compact!
# debugger
return true if(ary.count!=ary.uniq.count)
end
false
end
def files_with_noname?
[self.javascripts, self.images,self.themes].each do |objects_hash|
objects_hash.each{ |k|
return true if(k.file_filename.nil? && !k.to_save?)
}
end
false
end
def new_files=(*attrs)
attrs[0].map do |key,items_ary| #Loop by JSs,Themes,Imgs
self.files=([items_ary, key])
end
end
def javascripts=(*attrs) def javascripts=(*attrs)
self.files = (attrs << 'javascripts') self.files = (attrs << 'javascripts')
end end
@ -36,7 +65,7 @@ class Design
self.files = (attrs << 'images') self.files = (attrs << 'images')
end end
# Update or create the attribute_model records # Update or create the attribute records
def files=(attrs) def files=(attrs)
case attrs.last case attrs.last
when 'layout' when 'layout'
@ -45,6 +74,7 @@ class Design
files = eval(attrs.last) files = eval(attrs.last)
end end
attrs[0].each do |a| attrs[0].each do |a|
if a[:id].blank? && !a[:file].blank? if a[:id].blank? && !a[:file].blank?
files.build(:file => a[:file], :to_save => true) files.build(:file => a[:file], :to_save => true)
else else
@ -86,12 +116,14 @@ class Design
end end
end end
end end
self.valid?
end end
def process_object(object) def process_object(object)
if object.to_save if object.to_save
if object.file_filename.nil? if object.file_filename.nil?
new_object = self.send(object._type.downcase.pluralize).build(object) new_object = self.send(object._type.downcase.pluralize).build(object.attributes)
new_object.file = object.file
object.destroy object.destroy
new_object.to_save = false new_object.to_save = false
new_object.save new_object.save

View File

@ -1,5 +1,5 @@
class Layout < DesignFile class Layout < DesignFile
include Parser include ParserLayout
attr_reader :content attr_reader :content

View File

@ -7,6 +7,8 @@ class I18nVariable
field :document_class, :type => String field :document_class, :type => String
field :parent_id, :type => BSON::ObjectId, :index => true field :parent_id, :type => BSON::ObjectId, :index => true
belongs_to :language_value, polymorphic: true
def method_missing(field) def method_missing(field)
self[field] self[field]
end end

View File

@ -2,7 +2,7 @@ class ModuleApp
include Mongoid::Document include Mongoid::Document
include Mongoid::Timestamps include Mongoid::Timestamps
field :name_of_app field :title
field :version field :version
field :organization field :organization
field :author field :author
@ -10,4 +10,8 @@ class ModuleApp
field :update_info field :update_info
field :create_date field :create_date
field :app_pages ,type: Array
has_one :app_auth,dependent: :delete
end end

View File

@ -1,10 +1,12 @@
class Page < Item class Page < Item
field :content field :content
field :app_frontend_url
field :theme_id, :type => BSON::ObjectId, :default => nil field :theme_id, :type => BSON::ObjectId, :default => nil
belongs_to :design belongs_to :design
has_many :page_parts has_many :page_parts
belongs_to :module_app
embeds_many :custom_images, as: :design_image embeds_many :custom_images, as: :design_image

View File

@ -9,4 +9,8 @@ class Purchase
field :downloaded, :type => Boolean field :downloaded, :type => Boolean
field :download_date, :type => Date field :download_date, :type => Date
field :type
field :app_controller
has_many :app_auths
end end

View File

@ -0,0 +1,26 @@
class Attribute
include Mongoid::Document
include Mongoid::Timestamps
field :key
field :built_in, :type => Boolean, :default => false
field :disabled, :type => Boolean, :default => false
has_many :attribute_fields, :autosave => true, :dependent => :destroy
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :attribute_fields, :allow_destroy => true
def is_built_in?
self.built_in
end
def is_disabled?
self.disabled
end
def get_enabled_attribute_fields
self.attribute_fields.excludes('disabled' => true)
end
end

View File

@ -0,0 +1,37 @@
class AttributeField
include Mongoid::Document
include Mongoid::Timestamps
field :key
field :markup
field :locale, :type => Boolean, :default => true
field :list_options, :type => Array
field :built_in, :type => Boolean, :default => false
field :disabled, :type => Boolean, :default => false
belongs_to :attribute
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
has_many :attribute_values
# validates_uniqueness_of :key
# Convert the string list_options into an array
def select_list_options=(var)
self.list_options = var.gsub(' ', '').split(',')
end
# Convert the array list_options into a string
def select_list_options
self.list_options.to_a.join(', ')
end
def is_built_in?
self.built_in
end
def is_disabled?
self.disabled
end
end

View File

@ -1,62 +0,0 @@
class AttributeModel
include Mongoid::Document
include Mongoid::Timestamps
field :key
field :i18n_variable_id, :type => BSON::ObjectId, :index => true
field :markup
field :locale, :type => Boolean
field :list_options, :type => Array
field :built_in, :type => Boolean, :default => false
field :disabled, :type => Boolean, :default => false
embedded_in :user_attribute_model
validates_uniqueness_of :key
# Destroy the i18n_variable
def destroy_i18n_variable
self.i18n_variable.destroy rescue nil
end
# Get the i18n_variable
def i18n_variable
@i18n_variable ||= I18nVariable.find(self.i18n_variable_id) rescue nil
end
# Update or create the i18n_variable record
def i18n_variable=(attr)
if self.i18n_variable_id
self.i18n_variable.update_attributes(attr)
else
# var = I18nVariable.new(attr.merge({:key => self.key, :document_class => self.class, :parent_id => self.user_attribute_model.i18n_variable_id}))
var = I18nVariable.new(attr.merge({:key => self.key, :document_class => self.class}))
var.save
self.i18n_variable_id = var.id
end
end
# Convert the string list_options into an array
def select_list_options=(var)
self.list_options = var.gsub(' ', '').split(',')
end
# Convert the array list_options into a string
def select_list_options
self.list_options.to_a.join(', ')
end
# Check if the attribute is set to be destroyed
def should_destroy?
should_destroy.to_i == 1 rescue nil
end
def is_built_in?
self.built_in
end
def is_disabled?
self.disabled
end
end

View File

@ -5,6 +5,11 @@ class AttributeValue
field :key field :key
belongs_to :user_attribute belongs_to :attribute_field
belongs_to :user
def method_missing(field)
self[field]
end
end end

3
app/models/user/info.rb Normal file
View File

@ -0,0 +1,3 @@
class Info < Attribute
end

29
app/models/user/role.rb Normal file
View File

@ -0,0 +1,29 @@
class Role
include Mongoid::Document
include Mongoid::Timestamps
field :key
field :built_in, :type => Boolean, :default => false
field :disabled, :type => Boolean, :default => false
has_many :sub_roles, :autosave => true, :dependent => :destroy
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
has_many :users
accepts_nested_attributes_for :i18n_variable, :allow_destroy => true
accepts_nested_attributes_for :sub_roles, :allow_destroy => true
def is_built_in?
self.built_in
end
def is_disabled?
self.disabled
end
# Get an role from key
def self.get_role_from_key(key)
self.first(:conditions => {:key => key})
end
end

View File

@ -0,0 +1,11 @@
class SubRole < Attribute
belongs_to :role
has_and_belongs_to_many :users
# Get an sub_role from key
def self.get_sub_role_from_key(key)
self.first(:conditions => {:key => key})
end
end

View File

@ -10,53 +10,37 @@ class User
field :admin, :type => Boolean, :default => true field :admin, :type => Boolean, :default => true
field :active_role field :active_role
has_many :user_attributes has_many :attribute_values, :autosave => true, :dependent => :destroy
has_many :user_roles has_many :app_auths,as: :privilege_apps,:inverse_of => :privilege_lists
has_many :user_infos has_many :blocked_apps, :inverse_of => :blocked_users, :class_name => "AppAuth"
has_many :privilege_apps, :inverse_of => :privilege_users, :class_name => "AppAuth"
belongs_to :role
has_and_belongs_to_many :sub_roles
accepts_nested_attributes_for :attribute_values, :allow_destroy => true
# Update or create the user_role records def avb_apps
def user_roles=(*attrs) query = AppAuth.any_of({all: true},{privilege_user_ids: self.id},{roles: self.role.id}).excludes(blocked_user_ids: self.id)
attrs[0].each do |roles|
if roles[:id].blank?
user_roles.build(roles)
else
user_role = user_roles.detect {|a| a.id.to_s == roles[:id].to_s }
user_role.update_attributes(roles)
end
end
end
# Update or create the user_info records
def user_infos=(*attrs)
attrs[0].each do |infos|
if infos[:id].blank?
user_infos.build(infos)
else
user_info = user_infos.detect {|a| a.id.to_s == infos[:id].to_s }
user_info.update_attributes(infos)
end
end
end
# Get an user_info from model key
def get_info_from_model_key(key)
self.user_infos.detect {|a| a.key.to_s == key.to_s }
end
# Get an user_role from model key
def get_role_from_model_key(key)
self.user_roles.detect {|a| a.key.to_s == key.to_s }
end end
def name def name
infos = self.user_infos.detect {|info| info.key.to_s.eql?('profile') } info = Class::Info.first(:conditions => {:key => 'profile'})
if infos if info
first_name = infos.attribute_values.detect {|value| value.key.to_s.eql?('first_name') }[I18n.locale.to_s] rescue nil first_name = get_attribute_values.detect {|value| value.key.to_s.eql?('first_name') }[I18n.locale.to_s] rescue nil
last_name = infos.attribute_values.detect {|value| value.key.to_s.eql?('last_name') }[I18n.locale.to_s] rescue nil last_name = get_attribute_values.detect {|value| value.key.to_s.eql?('last_name') }[I18n.locale.to_s] rescue nil
return "#{first_name} #{last_name}" return "#{first_name} #{last_name}"
else else
return nil return nil
end end
end end
def get_attribute_values
@attribute_values ||= self.attribute_values
end
def get_value_from_field_id(field_id)
values = get_attribute_values
value = values.detect {|value| value.attribute_field_id == field_id} rescue nil
value ? value : self.attribute_values.build
end
end end

View File

@ -1,21 +0,0 @@
class UserAttribute
include Mongoid::Document
include Mongoid::Timestamps
field :key
has_many :attribute_values
# Update or create the attribute_value records
def attribute_values=(*args)
args[0].each do |value|
if value[:id].blank?
attribute_values.build(value)
else
attribute_value = attribute_values.detect {|a| a.id.to_s == value[:id].to_s }
attribute_value.update_attributes(value)
end
end
end
end

View File

@ -1,74 +0,0 @@
class UserAttributeModel
include Mongoid::Document
include Mongoid::Timestamps
field :key
field :i18n_variable_id, :type => BSON::ObjectId, :index => true
field :built_in, :type => Boolean, :default => false
field :disabled, :type => Boolean, :default => false
embeds_many :attribute_models
after_update :destroy_attrs
# Update or create the attribute_model records
def attribute_models=(*attrs)
attrs[0].each do |attributes|
if attributes[:id].blank?
attribute_models.build(attributes)
else
attribute_model = attribute_models.detect {|a| a.id.to_s == attributes[:id].to_s }
attribute_model.update_attributes(attributes)
end
end
end
# Destroy the i18n_variables
def destroy_i18n_variables
self.i18n_variable.destroy rescue nil
self.attribute_models.each do |attr|
attr.destroy_i18n_variable
end
end
# Update or create the i18n_variable record
def i18n_variable=(attr)
if self.i18n_variable_id
self.i18n_variable.update_attributes(attr) rescue nil
else
var = I18nVariable.new(attr.merge({:key => self.key, :document_class => self.class}))
var.save
self.i18n_variable_id = var.id
end
end
# Get the i18n_variable
def i18n_variable
@i18n_variable ||= I18nVariable.find(self.i18n_variable_id) rescue nil
end
def is_built_in?
self.built_in
end
def is_disabled?
self.disabled.blank? ? false : self.disabled
end
def get_enabled_attribute_models
self.attribute_models.excludes('disabled' => true)
end
protected
# Destroy the i18n_variable for each attribute_models if marked to destroy
def destroy_attrs
attribute_models.each do |a|
if a.should_destroy?
a.destroy_i18n_variable
end
end
end
end

View File

@ -1,5 +0,0 @@
class UserInfo < UserAttribute
belongs_to :user
end

View File

@ -1,3 +0,0 @@
class UserInfoModel < UserAttributeModel
end

View File

@ -1,5 +0,0 @@
class UserRole < UserAttribute
belongs_to :user
end

View File

@ -1,8 +0,0 @@
class UserRoleModel < UserAttributeModel
# Get an user_role_model from key
def self.get_role_model_from_key(key)
self.first(:conditions => {:key => key})
end
end

View File

@ -0,0 +1,3 @@
<div class="auth_unit">
<%= unit%>
<div>

View File

@ -0,0 +1,32 @@
<% content_for :secondary do %>
<div id='user_list'>
<div class="role_list">
<h1>User Role</h1>
<ul class="list">
<% @roles.each do |role| %>
<li class="set_1"><%= link_to content_tag(:span, "Role") %></li>
<% end -%>
</ul>
</div>
</div>
<% end -%>
<h1><%= t('admin.list_app_auths') %></h1>
<table>
<tr>
<th><%= t('admin.app.name') %></th>
<th><%= t('admin.description') %></th>
</tr>
<% @app_auth_data.each do |app| %>
<tr>
<td><%= app[0][:app_obj].title %></td>
<% app[0][:auth_field].each do |unit| %>
<td>
<%= render :partial => "auth_unit",:locals => {:unit => unit } %>
</td>
<%end%>
</tr>
<% end %>
</table>

View File

@ -0,0 +1,34 @@
<tr id="<%= "attribute_#{attribute_field.id}" if !attribute_field.new_record? %>" class="list_item">
<td><%= attribute_field.new_record? ? (f.text_field :key) : attribute_field.key %></td>
<td class='select_mulitlingual' style='text-align:center'>
<%= f.check_box :locale %>
</td>
<%= f.fields_for :i18n_variable, (attribute_field.new_record? ? attribute_field.build_i18n_variable : attribute_field.i18n_variable) do |f| %>
<% @site_valid_locales.each do |locale| %>
<td><%= f.text_field locale, :style => "width:130px" %></td>
<% end %>
<% end %>
<td class='select_type'>
<%= f.select :markup, LIST[:markups], {}, {:style => "width:90px"} %>
<div <%= attribute_field[:markup].eql?('select') ? nil : "style='display:none'"%>>
<%= t('admin.options') %>:
<%= f.select "select_list_options", attribute_field.select_list_options, :style => "width:130px" %>
</div>
</td>
<td>
<span class="action">
<% if attribute_field.new_record? %>
<a href="#" class="delete"><%= t(:delete) %></a>
<% else %>
<%= f.hidden_field :id %>
<% if attribute_field.is_built_in? %>
<a href="#" class="switch" id="<%= attribute_field.id %>"></a>
<%= f.hidden_field :disabled, :value => attribute_field.is_disabled? , :class => 'built_in_state' %>
<% else %>
<a href="#" class="remove_existing_record"><%= t(:delete) %></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
<% end %>
<% end %>
</span>
</td>
</tr>

View File

@ -0,0 +1,14 @@
<% content_for :secondary do %>
<%= render 'admin/users/side_bar' %>
<% end %>
<div id="profile">
<%= form_for @attribute, :url => eval("admin_#{@attribute_type}_path(@attribute)") do |f| %>
<%= f.error_messages %>
<%= render :partial => "admin/#{@attribute_type}s/form", :locals => { :f => f, :is_new => false } %>
<div class='button_bar'>
<%= link_back %>
<%= link_to t('update'), "#", :onclick=>"$('#edit_#{@attribute_type}_#{@attribute.id}').submit()" %>
</div>
<% end %>
</div>

View File

@ -0,0 +1,39 @@
<% content_for :secondary do %>
<%= render 'admin/users/side_bar' %>
<% end %>
<div class="main_list">
<div class="button_bar up">
<%= link_to t("admin.new_#{@attribute_type}"), eval("new_admin_#{@attribute_type}_path"), :class => 'new' %>
</div>
<table>
<thead>
<tr>
<td class="<%= @attribute_type %>s"><%= t("admin.#{@attribute_type}") %></td>
<td class="action"><%= t('admin.action') %></td>
</tr>
</thead>
<tbody>
<% @attributes.each do |attribute| %>
<tr id="attribute_<%= attribute.id %>" class="have <%= "#{attribute.is_disabled? ? 'disable' : ''}" %>">
<td class="<%= @attribute_type %>s <%= attribute.key.downcase %>"><%= attribute.i18n_variable[I18n.locale] %></span>
<td class="action">
<%= link_to t(:edit), eval("edit_admin_#{@attribute_type}_path(attribute)"), :class => 'edit' %>
<%= link_to t(:enable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{@attribute_type} => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? 'none' : ''}", :class => 'switch' %>
<%= link_to t(:disable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{@attribute_type} => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? '' : 'none'}", :class => 'switch' %>
<% if !attribute.is_built_in? %>
<%= link_to t(:delete), eval("admin_#{@attribute_type}_path(attribute)"), :class => 'delete', :confirm => t('sure?'), :method => :delete %>
<% end %>
</td>
</tr>
<tr>
<td colspan="5"></td>
</tr>
<% end %>
</tbody>
</table>
<div class="button_bar">
<%= link_to t("admin.new_#{@attribute_type}"), eval("new_admin_#{@attribute_type}_path"), :class => 'new' %>
</div>
</div>

View File

@ -0,0 +1,14 @@
<% content_for :secondary do %>
<%= render 'admin/users/side_bar' %>
<% end %>
<div id="profile">
<%= form_for @attribute, :url => eval("admin_#{@attribute_type}s_path") do |f| %>
<%= f.error_messages %>
<%= render :partial => "admin/#{@attribute_type}s/form", :locals => { :f => f, :is_new => true } %>
<div class="button_bar">
<%= link_back %>
<%= link_to t('create'), "#", :onclick=>"$('#new_#{@attribute_type}').submit()" %>
</div>
<% end -%>
</div>

View File

@ -0,0 +1,3 @@
$("#enable_<%= @attribute.id %>").toggle();
$("#disable_<%= @attribute.id %>").toggle();
$("#attribute_<%= @attribute.id %>").toggleClass('disable');

View File

@ -18,7 +18,7 @@
<% end %> <% end %>
</ul> </ul>
<p class="new_file"> <p class="new_file">
<%= fields_for "design[" + field_name + "][]", object.send(field_name).build, :index => nil do |f| %> <%= fields_for "design[new_files][" + field_name + "][]", object.send(field_name).build, :index => nil do |f| %>
<%= f.file_field :file, :class => "multi_files" %> <%= f.file_field :file, :class => "multi_files" %>
</p> </p>
<% end %> <% end %>

View File

@ -0,0 +1,10 @@
<h1><%= t('admin.new_design') %></h1>
<%= form_for :design, :url => admin_designs_path do |f| %>
<%= f.error_messages %>
<%= render :partial => "form", :locals => { :f => f } %>
<p>
<%= f.submit t('create') %> <%= link_back %>
</p>
<% end %>

View File

@ -1,6 +1,6 @@
<h1><%= t('admin.editing_design') %></h1> <h1><%= t('admin.editing_design') %></h1>
<%= form_for @design, :url => admin_design_path(@design) do |f| %> <%= form_for @design, :url => admin_design_path(@design),:html => {:multipart => true} do |f| %>
<%= f.error_messages %> <%= f.error_messages %>
<%= render :partial => "form", :locals => { :f => f } %> <%= render :partial => "form", :locals => { :f => f } %>
<p> <p>

View File

@ -1,7 +1,7 @@
<div class="main2"> <div class="main2">
<h1><%= t('admin.new_design') %></h1> <h1><%= t('admin.new_design') %></h1>
<%= form_for :design, :url => admin_designs_path do |f| %> <%= form_for :design, :url => admin_designs_path, :html => {:multipart => true} do |f| %>
<%= f.error_messages %> <%= f.error_messages %>
<%= render :partial => "form", :locals => { :f => f } %> <%= render :partial => "form", :locals => { :f => f } %>
@ -10,4 +10,4 @@
<%= f.submit t('create') %> <%= f.submit t('create') %>
</div> </div>
<% end %> <% end %>
</div> </div>

View File

@ -0,0 +1 @@
rcom.modalWindow({loadHtml:"<%= escape_javascript(render(:partial => 'new')) %>"});

View File

@ -0,0 +1,3 @@
<%= f.fields_for :attribute_fields, attribute_field do |f| %>
<%= render :partial => 'admin/attributes/attribute_field', :object => attribute_field, :locals => {:f => f} %>
<% end %>

View File

@ -0,0 +1,70 @@
<div class="attributes_block <%= @class %>">
<h2><%= t("admin.#{@attribute_type}") %></h2>
<div class="info_input">
<table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t('admin.key') %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</tr>
</thead>
<tbody>
<tr class="list_item">
<td><%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @attribute.key %></td>
<%= f.fields_for :i18n_variable, (@attribute.new_record? ? @attribute.build_i18n_variable : @attribute.i18n_variable) do |f| %>
<% @site_valid_locales.each do |locale| %>
<td><%= f.text_field locale, :style => "width:150px" %></td>
<% end %>
<% end %>
</tr>
</tbody>
</table>
</div>
</div>
<div class="attributes_block <%= @class %>">
<h2>Attributes</h2>
<div class="info_input">
<table id='attributes' border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t('admin.key') %></td>
<td><%= t('admin.multilingual') %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
<td><%= t('admin.type')%></td>
<td>&nbsp;</td>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="5">
<%= hidden_field_tag 'attribute_field_count', @attribute.attribute_fields.count %>
<a href="#" class="add"><%= t(:add) %></a>
</td>
</tr>
</tfoot>
<tbody>
<% @attribute.attribute_fields.each do |attribute_field| %>
<%= render :partial => 'attribute_field', :object => attribute_field, :locals => {:f => f} %>
<% end %>
</tbody>
</table>
</div>
</div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "attribute_form" %>
<script>
$('.attributes_block a.add').live('click', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_attribute_fields", "g");
$(this).prev().attr('value', parseInt(new_id) + 1);
$('#attributes').append(("<%= escape_javascript(add_attribute 'admin/attributes/attribute_field', f, :attribute_fields) %>").replace(old_id, new_id));
});
</script>
<% end %>

View File

@ -0,0 +1 @@
<%= f.select :module_app, @apps.collect { |t| [t.title.capitalize, t.id] }, {:include_blank => true} ,{:rel => admin_module_apps_path } %>

View File

@ -0,0 +1 @@
$('#app_page_url').html("<%= escape_javascript(select 'page','app_frontend_url', @module_app.app_pages) %>");

View File

@ -30,8 +30,13 @@
<%= f.select :theme_id, @default_design.themes.collect { |t| [t.name.capitalize, t.id] }, :include_blank => true %> <%= f.select :theme_id, @default_design.themes.collect { |t| [t.name.capitalize, t.id] }, :include_blank => true %>
<% end %> <% end %>
</p> </p>
<p>
<%= t('admin.module_app') %>
<%= render :partial => "admin/module_apps/app_selector", :locals => { :f => f } %>
<span id="app_page_url"></span>
</p>
<p> <p>
<%= f.label :is_published, "#{t('admin.is_published')} ?" %> <%= f.label :is_published, "#{t('admin.is_published')} ?" %>
<%= f.radio_button :is_published, true %>Yes <%= f.radio_button :is_published, false %> No <%= f.radio_button :is_published, true %>Yes <%= f.radio_button :is_published, false %> No
</p> </p>

View File

@ -1,7 +1,3 @@
<%= flash_messages %> <%= flash_messages %>
<%= parse_page_edit(@item).html_safe %> <%= parse_page_edit(@item).html_safe %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "page_edit" %>
<% end -%>

View File

@ -0,0 +1,3 @@
<%= f.fields_for :attribute_fields, attribute_field do |f| %>
<%= render :partial => 'admin/attributes/attribute_field', :object => attribute_field, :locals => {:f => f} %>
<% end %>

View File

@ -0,0 +1,50 @@
<div class="attributes_block <%= @class %>">
<h2><%= t("admin.#{@attribute_type}") %></h2>
<div class="info_input">
<table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t('admin.key') %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</tr>
</thead>
<tbody>
<tr class="list_item">
<td><%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @attribute.key %></td>
<%= f.fields_for :i18n_variable, (@attribute.new_record? ? @attribute.build_i18n_variable : @attribute.i18n_variable) do |f| %>
<% @site_valid_locales.each do |locale| %>
<td><%= f.text_field locale, :style => "width:150px" %></td>
<% end %>
<% end %>
</tr>
</tbody>
</table>
</div>
</div>
<div id='sub_roles' class="attributes_block <%= @class %>">
<h2>Sub roles</h2>
<% @attribute.sub_roles.each_with_index do |sub_role, i| %>
<%= render :partial => 'form_sub', :object => sub_role, :locals => {:f => f, :i => i} %>
<% end %>
</div>
</div>
<div id='add_sub_role' class="info_input attributes_block">
<%= hidden_field_tag 'attribute_field_count', @attribute.sub_roles.count %>
<a href="#" class="add"><%= t(:add) %></a>
</div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "attribute_form" %>
<script>
$('#add_sub_role a.add').live('click', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_sub_roles", "g");
$(this).prev().attr('value', parseInt(new_id) + 1);
$('#sub_roles').append(("<%= escape_javascript(add_attribute 'admin/roles/sub_role', f, :sub_roles) %>").replace(old_id, new_id));
});
</script>
<% end %>

View File

@ -0,0 +1,3 @@
<%= f.fields_for :sub_roles, form_sub do |f| %>
<%= render :partial => 'sub_role', :object => form_sub, :locals => {:f => f, :i => i} %>
<% end %>

View File

@ -0,0 +1,68 @@
<div class="info_input">
<table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t('admin.key') %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</tr>
</thead>
<tbody>
<tr class="list_item">
<td><%= sub_role.new_record? ? (f.text_field :key, {:style => "width:150px"}) : sub_role.key %></td>
<%= f.fields_for :i18n_variable, (sub_role.new_record? ? sub_role.build_i18n_variable : sub_role.i18n_variable) do |f| %>
<% @site_valid_locales.each do |locale| %>
<td><%= f.text_field locale, :style => "width:150px" %></td>
<% end %>
<% end %>
</tr>
</tbody>
</table>
<div class="attributes_block <%= @class %>">
<h2>Attributes</h2>
<div class="info_input">
<table class="sub_role_attributes" border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t('admin.key') %></td>
<td><%= t('admin.multilingual') %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
<td><%= t('admin.type')%></td>
<td>&nbsp;</td>
</tr>
</thead>
<tfoot>
<tr>
<td id='add_attribute' colspan="5">
<%= hidden_field_tag 'attribute_field_count', sub_role.attribute_fields.count %>
<a href="#" class="add"><%= t(:add) %></a>
<%= hidden_field_tag 'sub_role_temp_id', (i rescue 'new_sub_roles') %>
</td>
</tr>
</tfoot>
<tbody>
<% sub_role.attribute_fields.each do |attribute_field| %>
<%= render :partial => 'attribute_field', :object => attribute_field, :locals => {:f => f} %>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
<% content_for :page_specific_javascript do %>
<script>
$('#add_attribute a.add').live('click', function(){
var new_parent_id = $(this).next().attr('value');
var old_parent_id = new RegExp("new_sub_roles", "g");
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_attribute_fields", "g");
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parents('table').append(("<%= escape_javascript(add_attribute 'admin/attributes/attribute_field', f, :attribute_fields) %>").replace(old_id, new_id).replace(old_parent_id, new_parent_id));
});
</script>
<% end unless !sub_role.new_record? %>

View File

@ -1,36 +0,0 @@
<%= fields_for "user_#{@attribute}_model[attribute_models][]", attribute_model, :index => nil do |f| %>
<tr class="list_item">
<td><%= attribute_model.new_record? ? (f.text_field :key) : attribute_model.key %></td>
<td class='select_mulitlingual' style='text-align:center'>
<%= check_box_tag "locale[]", value = '', attribute_model.locale.nil? ? true : attribute_model.locale %>
<%= hidden_field_tag "user_#{@attribute}_model[attribute_models][][locale]", attribute_model.locale.nil? ? true : attribute_model.locale %>
</td>
<% @site_valid_locales.each do |locale| %>
<td><%= text_field_tag "user_#{@attribute}_model[attribute_models][][i18n_variable][#{locale}]", (attribute_model.i18n_variable[locale] rescue nil), :style => "width:130px" %></td>
<% end %>
<td class='select_type'>
<%= f.select :markup, LIST[:markups], {}, {:style => "width:90px"} %>
<div <%= attribute_model[:markup].eql?('select') ? nil : "style='display:none'"%>>
<%= t('admin.options') %>:
<%= text_field_tag "user_#{@attribute}_model[attribute_models][][select_list_options]", attribute_model.select_list_options, :style => "width:130px" %>
</div>
</td>
<td>
<span class="action">
<% if attribute_model.new_record? %>
<a href="#" class="delete"><%= t(:delete) %></a>
<% else %>
<% if attribute_model.is_built_in? %>
<a href="#" class="change_built_in switch" id="<%= attribute_model.id %>"></a>
<%= hidden_field_tag "user_#{@attribute}_model[attribute_models][][disabled]", attribute_model.is_disabled? , :class => 'built_in_state' %>
<% else %>
<a href="#" class="remove_existing_record delete"><%= t(:delete) %></a>
<%= hidden_field_tag "user_#{@attribute}_model[attribute_models][][should_destroy]", nil , :class => 'should_destroy' %>
<% end %>
<%= f.hidden_field :id %>
<%= f.hidden_field :key %>
<% end %>
</span>
</td>
</tr>
<% end %>

View File

@ -1,57 +0,0 @@
<div id="UserRole_block" class="roles_block <%= @class %>">
<h2><%= t("admin.user_#{@attribute}") %></h2>
<div class="info_input">
<table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t('admin.key') %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</tr>
</thead>
<tbody>
<tr class="list_item">
<td><%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @user_attribute_model.key %></td>
<% @site_valid_locales.each do |locale| %>
<td>
<%= text_field_tag "user_#{@attribute}_model[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %>
</td>
<% end %>
</tr>
</tbody>
</table>
</div>
</div>
<div id="attributes_block" class="roles_block <%= @class %>">
<h2>Attributes</h2>
<div class="info_input">
<table id='attributes' border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t('admin.key') %></td>
<td><%= t('admin.multilingual') %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
<td><%= t('admin.type')%></td>
<td>&nbsp;</td>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="5"><a href="#" class="add"><%= t(:add) %></a></td>
</tr>
</tfoot>
<tbody>
<%= render :partial => 'admin/user_attribute_models/attribute_model', :collection => @user_attribute_model.attribute_models %>
</tbody>
</table>
</div>
</div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "user_attribute_model_form" %>
<% end -%>

View File

@ -1,31 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><%= @title || APP_CONFIG['orbit'] %></title>
<link rel="shortcut icon" href="/favicon.ico">
<%= stylesheet_link_tag "admin" %>
<%= javascript_include_tag "admin" %>
<%= yield :page_specific_css %>
<%= yield :page_specific_javascript %>
<%= csrf_meta_tag %>
</head>
<body>
<div id="panel_banner_link" >
<div id="orbit"><%= render 'layouts/drop_down_menu' %></div>
<div class="hmenu">
<div class="lang"><%= render 'layouts/lang_menu' %></div>
<%= render 'devise/menu/login_items' %>
</div>
</div>
<div id="content">
<div id="sidebar"><%= yield :secondary %></div>
<div class="main">
<%= yield %>
</div>
<div class="tertiary"><%= yield :tertiary %></div>
<div id="panel_footer"><p><%= APP_CONFIG['ruling_digital'] %></p></div>
</div>
</body>
</html>

View File

@ -1,14 +0,0 @@
<% content_for :secondary do %>
<%= render 'admin/users/side_bar' %>
<% end %>
<div id="porfile" class="clear">
<%= form_for @user_attribute_model, :url => eval("admin_user_#{@attribute}_model_path(@user_role_model)") do |f| %>
<%= f.error_messages %>
<%= render :partial => "admin/user_attribute_models/form", :locals => { :f => f, :is_new => false } %>
<div class="button_bar">
<%= link_to t('update'), "#", :onclick=>"$('#edit_user_role_model_#{@user_attribute_model.id}').submit()" %>
<%= link_back %>
</div>
<% end -%>
</div>

View File

@ -1,14 +0,0 @@
<% content_for :secondary do %>
<%= render 'side_bar' %>
<% end %>
<div id="porfile">
<%= form_for @user, :url => admin_user_path(@user), :html => { :multipart => true } do |f| %>
<%= f.error_messages %>
<%= render :partial => 'form', :locals => { :f => f } %>
<div class="button_bar">
<%= link_back %>
<%= link_to t('update'), "#", :onclick=>"$('#edit_user_#{@user.id}').submit()" %>
</div>
<% end -%>
</div>

View File

@ -1,41 +0,0 @@
<% content_for :secondary do %>
<%= render 'admin/users/side_bar' %>
<% end %>
<div class="main_list clear">
<div class="button_bar up">
<%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path"), :class => 'new' %>
</div>
<table>
<thead>
<tr>
<td class="<%= @attribute %>s"><%= t("admin.#{@attribute}") %></td>
<td class="action"><%= t('admin.action') %></td>
</tr>
</thead>
<tbody>
<% @user_attribute_models.each do |user_attribute_model| %>
<tr id="attribute_<%= user_attribute_model.id %>" class="have <%= "#{user_attribute_model.is_disabled? ? 'disable' : ''}" %>">
<td class="<%= @attribute %>s <%= user_attribute_model.i18n_variable[:key].downcase %>"><%= user_attribute_model.i18n_variable[I18n.locale] %></td>
<td class="action">
<%= link_to t(:edit), eval("edit_admin_user_#{@attribute}_model_path(user_attribute_model)"), :class => 'edit' %>
<% if user_attribute_model.is_built_in? %>
<%= link_to t(:enable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? 'none' : ''}", :class => 'switch' %>
<%= link_to t(:disable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? '' : 'none'}", :class => 'switch' %>
<% else %>
<%= link_to t(:enable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? 'none' : ''}", :class => 'switch' %>
<%= link_to t(:disable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? '' : 'none'}", :class => 'switch' %>
<%= link_to t(:delete), eval("admin_user_#{@attribute}_model_path(user_attribute_model)"), :class => 'delete', :confirm => t('sure?'), :method => :delete %>
<% end %>
</td>
</tr>
<tr>
<td colspan="5"></td>
</tr>
<% end %>
</tbody>
</table>
<div class="button_bar">
<%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path"), :class => 'new' %>
</div>
</div>

View File

@ -1,18 +0,0 @@
<% content_for :secondary do %>
<%= render 'admin/users/side_bar' %>
<% end %>
<div id="porfile" class="clear">
<%= form_for @user_attribute_model, :url => eval("admin_user_#{@attribute}_models_path") do |f| %>
<%= f.error_messages %>
<%= render :partial => "admin/user_attribute_models/form", :locals => { :f => f, :is_new => true } %>
<div class="button_bar">
<%= link_back %>
<%= link_to t('create'), "#", :onclick=>"$('#new_user_attribute_model').submit()" %>
</div>
<% end -%>
</div>

View File

@ -1,3 +0,0 @@
$("#enable_<%= @user_attribute_model.id %>").toggle();
$("#disable_<%= @user_attribute_model.id %>").toggle();
$("#attribute_<%= @user_attribute_model.id %>").toggleClass('disable');

View File

@ -1,32 +0,0 @@
<p>
<%= f.label :name %>
<%= f.text_field :name %>
</p>
<fieldset>
<% @user_attribute.attrs.each_with_index do |attr, i| %>
<p>
<label><%= attr["key"] %></label>
<%= hidden_field_tag "user_attribute[attrs][][key]", attr["key"] %>
<%= text_field_tag "user_attribute[attrs][][name]", attr["name"] %>
<%= select_tag "user_attribute[attrs][][type]", options_for_select(["text_field", "select"], attr["type"]) %>
<a href="#" class="remove">(remove)</a>
</p>
<% end -%>
<p id="newone">
<label>Key</label>
<%= text_field_tag "user_attribute[attrs][][key]", "" %>
<label>Name</label>
<%= text_field_tag "user_attribute[attrs][][name]", "" %>
<%= select_tag "user_attribute[attrs][][type]", options_for_select(["text_field"], "") %>
<a href="#" class="remove">(remove)</a>
</p>
<a href="#" class="add">(add)</a>
</fieldset>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "user_attribute_form" %>
<% end -%>

View File

@ -1,12 +0,0 @@
<h1>Editing user attribute: <%= @user_attribute.key %></h1>
<% form_for @user_attribute, :url => admin_user_attribute_path(@user_attribute) do |f| %>
<%= render :partial => "form", :locals => { :f => f } %>
<p>
<%= f.submit %>
</p>
<% end -%>

View File

@ -1,34 +0,0 @@
<% content_for :secondary do %>
<%= render 'admin/users/side_bar' %>
<% end %>
<div class="main_list">
<div id="add_new" class="buttom clear">
<%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path") %>
</div>
<ul>
<li class="list_head clear">
<span class="<%= @attribute %>s"><%= t("admin.#{@attribute}") %></span>
<span class="action"><%= t('admin.action') %></span>
</li>
<% @user_attribute_models.each do |user_attribute_model| %>
<li id="attribute_<%= user_attribute_model.id %>" class="list_item <%= "#{user_attribute_model.is_disabled? ? 'disable' : ''}" %> clear">
<span class="<%= @attribute %>s <%= user_attribute_model.i18n_variable[:key].downcase %>"><%= user_attribute_model.i18n_variable[I18n.locale] %></span>
<span class="action">
<%= link_to t(:edit), eval("edit_admin_user_#{@attribute}_model_path(user_attribute_model)"), :class => 'edit' %>
<% if user_attribute_model.is_built_in? %>
<%= link_to t(:enable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? 'none' : ''}", :class => 'switch' %>
<%= link_to t(:disable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? '' : 'none'}", :class => 'switch' %>
<% else %>
<%= link_to t(:delete), eval("admin_user_#{@attribute}_model_path(user_attribute_model)"), :class => 'delete', :confirm => t('sure?'), :method => :delete %>
<% end %>
</span>
</li>
<% end %>
</ul>
<div id="add_new" class="buttom clear">
<%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path") %>
</div>
</div>

View File

@ -1,16 +0,0 @@
<h1>New user attribute: <%= @user_attribute.key %></h1>
<% form_for @user_attribute, :url => admin_user_attributes_path do |f| %>
<p>
<%= f.label :key, "Key" %>
<%= f.text_field :key %>
</p>
<%= render :partial => "form", :locals => { :f => f } %>
<p>
<%= f.submit %>
</p>
<% end -%>

View File

@ -16,28 +16,21 @@
</label> </label>
<label> <label>
<span><%= t('admin.role') %></span> <span><%= t('admin.role') %></span>
<%= f.select :active_role, @user_role_models.sort_by{|role| role.key }.collect {|role| [ role.i18n_variable[I18n.locale], role.key ]}, :selected => (@user.active_role || 'student') %> <%= f.select :role_id, @roles.sort_by{|role| role.key }.collect {|role| [ role.i18n_variable[I18n.locale], role.id ]}, :selected => (@user.role_id || Role.get_role_from_key('student')) %>
</label> </label>
</div> </div>
<% @user_info_models.each do |ua| %>
<div id="basic_block" class="roles_block <%= @class %>">
<h2><%= ua.i18n_variable[I18n.locale] %></h2>
<hr>
<%= render :partial => 'user_attribute',
:object => (@user.user_infos.detect {|u| u.key == ua.key } || @user.user_infos.build),
:locals => {:ua => ua, :type => 'info'} %>
</div>
<% end -%>
<div id='role_models'> <%= render :partial => 'info', :collection => @infos, :locals => {:f => f} %>
<% @user_role_models.each do |ua| %>
<div id="<%= ua.key %>_block" class="roles_block <%= @class %>" <%= raw(' style="display: none;"') unless ((@user.active_role.eql?(ua.key) rescue nil) || (ua.key.eql?('student') && @user.new_record?)) %>>
<h2><%= ua.i18n_variable[I18n.locale] %></h2> <div id='roles'>
<% @roles.each do |role| %>
<div id="<%= role.id %>_block" class="attributes_block <%= @class %>" <%= raw(' style="display: none;"') unless ((@user.role.id.eql?(role.id) rescue nil) || (role.key.eql?('student') && @user.new_record?)) %>>
<h2><%= role.i18n_variable[I18n.locale] %></h2>
<hr> <hr>
<%= render :partial => 'user_attribute', <%= render :partial => 'sub_role_selector', :locals => {:f => f, :role => role} %>
:object => (@user.user_roles.detect {|u| u.key == ua.key } || @user.user_roles.build), <%= render :partial => 'sub_role', :collection => role.sub_roles, :locals => {:f => f, :role => role} %>
:locals => {:ua => ua, :type => 'role'} %>
</div> </div>
<% end -%> <% end -%>
</div> </div>

View File

@ -0,0 +1,40 @@
<div id="basic_block" class="attributes_block <%= @class %>">
<h2><%= info.i18n_variable[I18n.locale] %></h2>
<hr>
<div class="info_input">
<table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t("admin.key") %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</tr>
</thead>
<tbody>
<% info.get_enabled_attribute_fields.each do |attr| %>
<%= f.fields_for :attribute_values, @user.get_value_from_field_id(attr.id) do |f| %>
<tr class="list_item">
<td><%= attr.i18n_variable[I18n.locale] %></td>
<% if attr["locale"] && attr["markup"] == 'text_field' %>
<% @site_valid_locales.each do |locale| %>
<td><%= f.text_field locale %></td>
<% end %>
<% else %>
<td colspan=<%= @site_valid_locales.size %>>
<% if attr["markup"] == "text_field" %>
<%= f.text_field :non_locale %>
<% elsif attr["markup"] == "select" %>
<%= f.select :non_locale, options_for_select(attr["options"], value['non_locale']) %>
<% end -%>
</td>
<% end -%>
<%= f.hidden_field :attribute_field_id, :value => attr.id %>
<%= f.hidden_field :key, :value => attr.key %>
</tr>
<% end %>
<% end %>
</tbody>
</table>
</div>
</div>

View File

@ -0,0 +1,26 @@
<div class="info_input">
<table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<td><%= t("admin.key") %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</thead>
<tbody>
<% show_attribute.get_enabled_attribute_fields.each do |attr| %>
<tr class="list_item">
<td><%= attr.i18n_variable[I18n.locale] %></td>
<% @site_valid_locales.each do |locale| %>
<td>
<% if attr["locale"] && attr["markup"] == 'text_field' %>
<%= show_attribute(@user, attr.id, locale) %>
<% else %>
<%= show_attribute(@user, attr.id) %>
<% end %>
</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>

View File

@ -0,0 +1,4 @@
<div id="sub_role_<%= show_sub_role.id %>" class="info_input">
<h2><%= show_sub_role.i18n_variable[I18n.locale] %></h2>
<%= render :partial => 'show_attribute', :object => show_sub_role %>
</div>

View File

@ -1,27 +0,0 @@
<div class="info_input">
<table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<td><%= t("admin.key") %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</thead>
<tbody>
<% am.get_enabled_attribute_models.each do |attr| %>
<tr class="list_item">
<td><%= attr.i18n_variable[I18n.locale] %></td>
<% @site_valid_locales.each do |locale| %>
<td>
<% if attr["locale"] && attr["markup"] == 'text_field' %>
<%= show_user_attribute(object, attr.key, locale) %>
<% else %>
<%= show_user_attribute(object, attr.key) %>
<% end %>
</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>

View File

@ -2,10 +2,10 @@
<input id="user_search" name="user[username]" size="30" type="text" /> <input id="user_search" name="user[username]" size="30" type="text" />
</div> </div>
<div class="member_setup <%= @class %>"> <div class="member_setup <%= @class %>">
<h1><%= t('admin.setup_member') %></h1> <h1><%= t('admin.setup_member') %></h1>
<ul class="list"> <ul class="list">
<li class="set_1"><%= link_to content_tag(:span, t('admin.list_users')), admin_users_path %></li> <li class="set_1"><%= link_to content_tag(:span, t('admin.list_users')), admin_users_path %></li>
<li class="set_2"><%= link_to content_tag(:span, t('admin.list_user_roles')), admin_user_role_models_path %></li> <li class="set_2"><%= link_to content_tag(:span, t('admin.list_roles')), admin_roles_path %></li>
<li class="set_3"><%= link_to content_tag(:span, t('admin.list_user_infos')), admin_user_info_models_path %></li> <li class="set_3"><%= link_to content_tag(:span, t('admin.list_infos')), admin_infos_path %></li>
</ul> </ul>
</div> </div>

View File

@ -0,0 +1,37 @@
<div id="sub_role_<%= sub_role.id %>" class="info_input" <%= raw(' style="display: none;"') unless @user.sub_role_ids.include?(sub_role.id) %>>
<h2><%= sub_role.i18n_variable[I18n.locale] %></h2>
<table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t("admin.key") %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</tr>
</thead>
<tbody>
<% sub_role.get_enabled_attribute_fields.each do |attr| %>
<%= f.fields_for :attribute_values, @user.get_value_from_field_id(attr.id) do |f| %>
<tr class="list_item">
<td><%= attr.i18n_variable[I18n.locale] %></td>
<% if attr["locale"] && attr["markup"] == 'text_field' %>
<% @site_valid_locales.each do |locale| %>
<td><%= f.text_field locale %></td>
<% end %>
<% else %>
<td colspan=<%= @site_valid_locales.size %>>
<% if attr["markup"] == "text_field" %>
<%= f.text_field :non_locale %>
<% elsif attr["markup"] == "select" %>
<%= f.select :non_locale, options_for_select(attr["options"], value['non_locale']) %>
<% end -%>
</td>
<% end -%>
<%= f.hidden_field :attribute_field_id, :value => attr.id %>
<%= f.hidden_field :key, :value => attr.key %>
</tr>
<% end %>
<% end %>
</tbody>
</table>
</div>

View File

@ -0,0 +1,4 @@
<% role.sub_roles.each do |sub_role| %>
<%= sub_role.i18n_variable[I18n.locale] %>
<%= check_box_tag "user[sub_role_ids][]", sub_role.id, @user.sub_role_ids.include?(sub_role.id), :class => 'sub_role_select' %>
<% end %>

View File

@ -1,44 +0,0 @@
<%= fields_for "user[user_#{type}s]", user_attribute, :index => nil do |f| %>
<%= f.hidden_field :key, :value => ua.key %>
<%= f.hidden_field :id unless user_attribute.new_record? %>
<div class="info_input">
<table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head">
<tr>
<td><%= t("admin.key") %></td>
<% @site_valid_locales.each do |locale| %>
<td><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></td>
<% end %>
</tr>
</thead>
<tbody>
<% ua.get_enabled_attribute_models.each do |attr| %>
<% value = user_attribute.attribute_values.detect{|v| v.key == attr.key } %>
<%= hidden_field_tag "user[user_#{type}s][][attribute_values][][id]", value.id rescue nil %>
<%= hidden_field_tag "user[user_#{type}s][][attribute_values][][key]", attr.key %>
<tr class="list_item">
<td><%= attr.i18n_variable[I18n.locale] %></td>
<% if attr["locale"] && attr["markup"] == 'text_field' %>
<%= hidden_field_tag "user[user_#{type}s][][attribute_values][][non_locale]", nil %>
<% @site_valid_locales.each do |locale| %>
<td>
<%= text_field_tag "user[user_#{type}s][][attribute_values][][#{locale}]", (value[locale] rescue nil) %>
</td>
<% end -%>
<% else %>
<td colspan=<%= @site_valid_locales.size %>>
<% if attr["markup"] == "text_field" %>
<%= text_field_tag "user[user_#{type}s][][attribute_values][][non_locale]", (value['non_locale'] rescue nil) %>
<% elsif attr["markup"] == "select" %>
<%= select_tag "user[user_#{type}s][][attribute_values][][non_locale]", options_for_select(attr["options"], value['non_locale']) %>
<% end -%>
</td>
<% end -%>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>

View File

@ -2,7 +2,7 @@
<%= render 'side_bar' %> <%= render 'side_bar' %>
<% end %> <% end %>
<div id="porfile" class="clear"> <div id="profile" class="clear">>
<%= form_for @user, :url => admin_user_path(@user), :html => { :multipart => true } do |f| %> <%= form_for @user, :url => admin_user_path(@user), :html => { :multipart => true } do |f| %>
<%= f.error_messages %> <%= f.error_messages %>
<%= render :partial => 'form', :locals => { :f => f } %> <%= render :partial => 'form', :locals => { :f => f } %>

View File

@ -19,9 +19,8 @@
</thead> </thead>
<tbody> <tbody>
<% @users.each do |user| %> <% @users.each do |user| %>
<% active_role = UserRoleModel.get_role_model_from_key(user.active_role) %>
<tr class="have"> <tr class="have">
<td class="roles <%= active_role.key.downcase rescue nil %>"><%= active_role.i18n_variable[I18n.locale] rescue nil %></td> <td class="roles <%= user.role.key.downcase rescue nil %>"><%= user.role.i18n_variable[I18n.locale] rescue nil %></td>
<td class="name"><%= user.name ? user.name : 'bob' %></td> <td class="name"><%= user.name ? user.name : 'bob' %></td>
<td class="email"><%= user.email %></td> <td class="email"><%= user.email %></td>
<td class="admin"><%= user.admin ? t(:yes_) : t(:no_) %></td> <td class="admin"><%= user.admin ? t(:yes_) : t(:no_) %></td>

View File

@ -2,7 +2,7 @@
<%= render 'side_bar' %> <%= render 'side_bar' %>
<% end %> <% end %>
<div id="porfile" class="clear"> <div id="profile" class="clear">
<%= form_for @user, :url => admin_users_path, :html => { :multipart => true } do |f| %> <%= form_for @user, :url => admin_users_path, :html => { :multipart => true } do |f| %>
<%= f.error_messages %> <%= f.error_messages %>
<%= render :partial => 'form', :locals => { :f => f } %> <%= render :partial => 'form', :locals => { :f => f } %>

View File

@ -2,29 +2,28 @@
<%= render 'side_bar' %> <%= render 'side_bar' %>
<% end %> <% end %>
<div id="porfile" class="clear"> <div id="profile" class="clear">
<div id="person"> <div id="person">
<% if @user.avatar? %> <% if @user.avatar? %>
<%= image_tag(@user.avatar.thumb.url) %> <%= image_tag(@user.avatar.thumb.url) %>
<% else %> <% else %>
<%= image_tag "person.png" %> <%= image_tag "person.png" %>
<% end %> <% end %>
<label><span><%= @user.email %></span></label>
</div> </div>
<% @infos.each do |a| %>
<% @user_info_models.each do |am| %>
<div id="basic_block" class="roles_block <%= @class %>"> <div id="basic_block" class="roles_block <%= @class %>">
<h2><%= am.i18n_variable[I18n.locale] %></h2> <h2><%= a.i18n_variable[I18n.locale] %></h2>
<hr> <hr>
<%= render :partial => 'show_user_attribute', :locals => {:am => am, :object => @user.get_info_from_model_key(am.key)} %> <%= render :partial => 'show_attribute', :object => a %>
</div> </div>
<% end -%> <% end -%>
<div id="<%= @user.active_role %>_block" class="roles_block <%= @class %>"> <div id="<%= @user.role.key %>_block" class="roles_block <%= @class %>">
<% active_role = UserRoleModel.get_role_model_from_key(@user.active_role) %> <h2><%= @user.role.i18n_variable[I18n.locale] %></h2>
<h2><%= active_role.i18n_variable[I18n.locale] %></h2>
<hr> <hr>
<%= render :partial => 'show_user_attribute', :locals => {:am => active_role, :object => @user.get_role_from_model_key(active_role.key)} %> <%= render :partial => 'show_sub_role', :collection => @user.sub_roles %>
</div> </div>
<div class="button_bar"> <div class="button_bar">
<%= link_to t(:edit), edit_admin_user_path(@user) %> <%= link_to t(:edit), edit_admin_user_path(@user) %>

View File

@ -15,10 +15,11 @@ Bundler.require *Rails.groups(:assets) if defined?(Bundler)
module PrototypeR4 module PrototypeR4
class Application < Rails::Application class Application < Rails::Application
# config.paths.vendor.plugins.instance_variable_set("@paths", config.paths.vendor.plugins.instance_variable_get("@paths") + ["#{config.root}/vendor/built_in_modules"]) # Add directories for plugins
# config.paths.vendor.plugins.instance_variable_set("@paths", config.paths.vendor.plugins.instance_variable_get("@paths") + ["#{config.root}/vendor/downloaded_modules"]) config.paths["vendor/plugins"] += %W(#{config.root}/vendor/built_in_modules)
# config.paths.vendor.plugins.instance_variable_set("@paths", config.paths.vendor.plugins.instance_variable_get("@paths") + ["#{config.root}/vendor/radius"]) config.paths["vendor/plugins"] += %W(#{config.root}/vendor/downloaded_modules)
# Settings in config/environments/* take precedence over those specified here. # Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers # Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded. # -- all .rb files in that directory are automatically loaded.
@ -26,7 +27,8 @@ module PrototypeR4
# Custom directories with classes and modules you want to be autoloadable. # Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras) # config.autoload_paths += %W(#{config.root}/extras)
config.autoload_paths += %W(#{config.root}/lib) config.autoload_paths += %W(#{config.root}/lib)
config.autoload_paths += %W( #{config.root}/app/models/ckeditor ) config.autoload_paths += %W(#{config.root}/lib/parsers)
config.autoload_paths += %W(#{config.root}/app/models/ckeditor )
config.autoload_paths += %W(#{config.root}/app/models/design) config.autoload_paths += %W(#{config.root}/app/models/design)
config.autoload_paths += %W(#{config.root}/app/models/purchase) config.autoload_paths += %W(#{config.root}/app/models/purchase)
config.autoload_paths += %W(#{config.root}/app/models/user) config.autoload_paths += %W(#{config.root}/app/models/user)

View File

@ -0,0 +1,5 @@
Module.instance_eval do
def using_object_ids?
false
end
end

View File

@ -1,6 +1,7 @@
forbidden_item_names: forbidden_item_names:
- admin - admin
- panel - panel
- appfront
markups: markups:
- text_field - text_field

View File

@ -55,8 +55,8 @@ en:
editing_link: Editing link editing_link: Editing link
editing_page: Editing page editing_page: Editing page
editing_snippet: Editing snippet editing_snippet: Editing snippet
editing_user_info: Editing user information editing_info: Editing user information
editing_user_role: Editing user role editing_role: Editing user role
email: Email email: Email
enable_language: Enable language enable_language: Enable language
file_name: Filename file_name: Filename
@ -78,8 +78,8 @@ en:
list_puchases: Purchases list list_puchases: Purchases list
list_snippets: Snippets list list_snippets: Snippets list
list_users: Users list list_users: Users list
list_user_infos: User information list list_infos: User information list
list_user_roles: User roles list list_roles: User roles list
member: Member member: Member
move_down: Move down move_down: Move down
move_up: Move up move_up: Move up
@ -97,8 +97,8 @@ en:
new_page: New page new_page: New page
new_snippet: New snippet new_snippet: New snippet
new_user: New user new_user: New user
new_user_info: New user information new_info: New user information
new_user_role: New user role new_role: New user role
non_multilingual: Non multilingual non_multilingual: Non multilingual
options: Options options: Options
orig_upload_file: Original filename orig_upload_file: Original filename
@ -128,8 +128,8 @@ en:
upload_design: Upload design upload_design: Upload design
url: URL url: URL
user: User user: User
user_info: User information info: User information
user_panel: User panel panel: User panel
user_role: User role role: User role
panel: panel:

View File

@ -50,8 +50,8 @@ zh_tw:
editing_link: 編輯連結 editing_link: 編輯連結
editing_page: 編輯頁面 editing_page: 編輯頁面
editing_snippet: 編輯片段 editing_snippet: 編輯片段
editing_user_info: 編輯用戶資料 editing_info: 編輯用戶資料
editing_user_role: 編輯用戶角色 editing_role: 編輯用戶角色
email: Email email: Email
enable_language: 啟用語言 enable_language: 啟用語言
file_name: 檔名 file_name: 檔名
@ -73,8 +73,8 @@ zh_tw:
list_layouts: 佈局列表 list_layouts: 佈局列表
list_snippets: 斷片列表 list_snippets: 斷片列表
list_users: 使用列表 list_users: 使用列表
list_user_infos: 用戶資料列表 list_infos: 用戶資料列表
list_user_roles: 用戶角色列表 list_roles: 用戶角色列表
member: 會員 member: 會員
move_down: 往下移 move_down: 往下移
move_up: 往上移 move_up: 往上移
@ -92,8 +92,8 @@ zh_tw:
new_page: 新增頁面 new_page: 新增頁面
new_snippet: 新增片段 new_snippet: 新增片段
new_user: 新增使用 new_user: 新增使用
new_user_info: 新增用戶資料 new_info: 新增用戶資料
new_user_role: 新增用戶角色 new_role: 新增用戶角色
non_multilingual: 非多種語言 non_multilingual: 非多種語言
options: 選項 options: 選項
orig_upload_file: 原上傳檔名 orig_upload_file: 原上傳檔名
@ -121,9 +121,9 @@ zh_tw:
upload_design: 上傳設計 upload_design: 上傳設計
url: URL url: URL
user: 用戶 user: 用戶
user_info: 用戶資料 info: 用戶資料
user_panel: 用戶面板 panel: 用戶面板
user_role: 用戶角色 role: 用戶角色
panel: panel:

Some files were not shown because too many files have changed in this diff Show More