Model commit

This commit is contained in:
Harry Bomrah 2012-04-03 18:25:41 +08:00 committed by Christophe Vilayphiou
parent 79f005c88e
commit f5c080efd4
7 changed files with 71 additions and 3 deletions

View File

@ -65,7 +65,7 @@ var orbitDesktop = function(dom){
}) })
$(window).resize(function(){ $(window).resize(function(){
var ww = $(window).width(); var ww = $(window).width();
$("img#thmbackground").attr({"width":ww}) $("img#thmbackground").attr({"width":ww});
}); });
$(o.contentHolder).mousemove(function(event){ $(o.contentHolder).mousemove(function(event){
/*if(($(window).width()-50)<=event.pageX){ /*if(($(window).width()-50)<=event.pageX){

View File

@ -1,6 +1,6 @@
class DesktopController< ApplicationController class DesktopController< ApplicationController
layout 'desktop' layout 'desktop'
before_filter :authenticate_user!
def index def index
end end
@ -16,4 +16,12 @@ class DesktopController< ApplicationController
def sections def sections
render :layout => false render :layout => false
end end
def save_desktop_theme
end
def get_desktop_theme
end
end end

16
app/models/desktop.rb Normal file
View File

@ -0,0 +1,16 @@
class Desktop
include Mongoid::Document
include Mongoid::Timestamps
field :theme, default: "default"
belongs_to :user
has_many :sections, :autosave => true, :dependent => :destroy
before_create :initialize_section
def initialize_section
user.self.build_section
end
end

14
app/models/group.rb Normal file
View File

@ -0,0 +1,14 @@
class Group
include Mongoid::Document
include Mongoid::Timestamps
belongs_to :section
has_many :tiles, :autosave => true, :dependent => :destroy
before_create :initialize_tile
def initialize_tile
self.build_tile
end
end

16
app/models/section.rb Normal file
View File

@ -0,0 +1,16 @@
class Section
include Mongoid::Document
include Mongoid::Timestamps
field :name, default: "Section"
belongs_to :desktop
has_many :groups, :autosave => true, :dependent => :destroy
before_create :initialize_group
def initialize_group
self.build_group
end
end

8
app/models/tile.rb Normal file
View File

@ -0,0 +1,8 @@
class Tile
include Mongoid::Document
include Mongoid::Timestamps
belongs_to :group
end

View File

@ -16,11 +16,13 @@ class User
has_many :privilege_apps, :inverse_of => :privilege_users, :class_name => "AppAuth" has_many :privilege_apps, :inverse_of => :privilege_users, :class_name => "AppAuth"
has_many :managing_apps,:class_name => "AppManager" has_many :managing_apps,:class_name => "AppManager"
has_one :desktop, :autosave => true, :dependent => :destroy
belongs_to :role belongs_to :role
has_and_belongs_to_many :sub_roles has_and_belongs_to_many :sub_roles
accepts_nested_attributes_for :attribute_values, :allow_destroy => true accepts_nested_attributes_for :attribute_values, :allow_destroy => true
before_create :initialize_desktop
def avb_apps def avb_apps
sub_role_ids_ary=self.sub_roles.collect{|t| t.id} sub_role_ids_ary=self.sub_roles.collect{|t| t.id}
query1 = AppAuth.any_in({sub_role_ids: sub_role_ids_ary}).excludes(blocked_user_ids: self.id) query1 = AppAuth.any_in({sub_role_ids: sub_role_ids_ary}).excludes(blocked_user_ids: self.id)
@ -53,4 +55,8 @@ class User
User.find(id) rescue nil User.find(id) rescue nil
end end
def initialize_desktop
self.build_desktop
end
end end