diff --git a/app/assets/javascripts/admin.js b/app/assets/javascripts/admin.js index 753b3f1..63043aa 100644 --- a/app/assets/javascripts/admin.js +++ b/app/assets/javascripts/admin.js @@ -1,9 +1,11 @@ $(function() { + $('.wl-no-script').hide(); + var reject_widget = function() { - $( "#admin_action_buttons" ).hide(); - $(".widget_confirmation").hide(); - $("#reject_confirm").show(); + $('#admin_action_buttons').hide(); + $('.widget_confirmation').hide(); + $('#reject_confirm').show(); }; var finalize_rejection = function( versionid ) { diff --git a/app/assets/stylesheets/admin.css.scss b/app/assets/stylesheets/admin.css.scss index 5b27d11..3f3e9ae 100644 --- a/app/assets/stylesheets/admin.css.scss +++ b/app/assets/stylesheets/admin.css.scss @@ -67,7 +67,6 @@ margin: 0; li { display: inline-block; - float: left; margin: 12px 0; width: 33%; } @@ -80,6 +79,15 @@ float: right; margin-right: 60px; } + a.wl-button { + margin: auto; + } + } + .wl-save-fallback { + font: 13px/1.231 Arial,Helvetica,sans-serif; + font-weight: bold; + height: 15px; + width: 25px; } .admin-table { color: #333; diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 61a83a5..26c4622 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -35,7 +35,12 @@ def user_update user.admin = params["chk_user_admin" + params[:user_id]] user.reviewer = params["chk_user_reviewer" + params[:user_id]] user.save - head :ok + redirect_to request.referer + end + + def delete_user + User.find(params[:id]).destroy + redirect_to request.referer end def options diff --git a/app/models/user.rb b/app/models/user.rb index 876ea60..9c22d32 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,6 +1,7 @@ class User < ActiveRecord::Base include ValidatesAsImage before_save :calculate_fields + after_destroy :destroy_inactive_widgets has_attached_file :avatar, :styles => { @@ -8,8 +9,8 @@ class User < ActiveRecord::Base :medium => ["100x100!", :png], :large => ["800x800", :png] }, :default_url => "register_default_image.jpg" - has_many :widgets - has_many :downloads + has_many :widgets, :dependent => :destroy + has_many :downloads, :dependent => :destroy # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, @@ -62,5 +63,8 @@ def calculate_fields self.name = "#{self.first_name} #{self.last_name}" self.url_title = "#{self.first_name.to_s.downcase}-#{self.last_name.to_s.downcase}" end - + def destroy_inactive_widgets + Widget.where("user_id = ?", self.id).destroy_all + Rating.where("user_id = ?", self.id).destroy_all + end end diff --git a/app/views/admin/_user.html.erb b/app/views/admin/_user.html.erb index 5819626..8d994e4 100644 --- a/app/views/admin/_user.html.erb +++ b/app/views/admin/_user.html.erb @@ -1,8 +1,16 @@ -<% @users.each do |user| %> -