Permalink
Browse files

Trimming old unit membership code

  • Loading branch information...
1 parent 0e22658 commit 560d3d726c68161f0168c5d0cd4aeb58624f7769 @jnraine committed Oct 22, 2011
@@ -1,21 +0,0 @@
-class Membership < ActiveRecord::Base
- belongs_to :user
- belongs_to :unit
-
- # Returns a list of ACLs columns in the DB
- def self.acls
- # Stores attributes that do not represent an ACL
- non_acl_attr = [:id,:unit_id,:updated_at,:user_id,:created_at]
- column_names.collect(&:to_sym).delete_if {|k,v| non_acl_attr.include?(k) }
- end
-
- # Return hash of acl attributes (as keys) and their values
- def acls
- h = {}
- Membership.acls.each do |acl|
- h[acl] = read_attribute(acl)
- end
- h
- end
-end
-
View
@@ -26,26 +26,6 @@ def name=(value)
write_attribute(:name,value)
end
- # Returns the membership that self and user share
- def membership(user)
- memberships.find_by_user_id(user.id)
- end
-
- # Ensures user is a valid member of this unit
- def member?(user)
- user_ids.include?(user.id)
- end
-
- # Alias to user association getter
- def members
- users
- end
-
- # Alias to user association setter
- def members=(value)
- self.users = value
- end
-
# Returns an array of tas option hashes
def tas_params(environment_id = nil)
[{:title => "Users",
@@ -60,11 +40,6 @@ def to_s
name
end
- # Generate key using the User.random_string method
- def self.generate_key
- User.random_string(30)
- end
-
def self.dormant_computers_mailers
Unit.all.map(&:dormant_computers_mailer)
end
View
@@ -56,15 +56,6 @@ def self.authenticate(username, pass)
return u if (u != nil) and (User.encrypt(pass, u.salt) == u.hashed_password)
end
- def member_of(unit)
- unit_ids.include?(unit.id)
- end
-
- # Returns membership that self and unit share
- def membership(unit)
- unit.membership(self)
- end
-
# Returns true if user is super user
def super_user?
true
@@ -95,8 +86,6 @@ def all_permissions
groups.map(&:permissions).flatten(1) + permissions
end
-
-
# Returns units through permission association. Couldn't get finder_sql
# to work, so I added a custom method instead.
def units
@@ -1,37 +0,0 @@
-class CreateMemberships < ActiveRecord::Migration
- def self.up
- create_table :memberships do |t|
- t.integer :unit_id
- t.integer :user_id
-
- # ACLs
- t.boolean :create_computer, :default => true
- t.boolean :read_computer, :default => true
- t.boolean :edit_computer, :default => true
- t.boolean :destroy_computer, :default => true
-
- t.boolean :create_bundle, :default => true
- t.boolean :read_bundle, :default => true
- t.boolean :edit_bundle, :default => true
- t.boolean :destroy_bundle, :default => true
-
- t.boolean :create_computer_group, :default => true
- t.boolean :read_computer_group, :default => true
- t.boolean :edit_computer_group, :default => true
- t.boolean :destroy_computer_group, :default => true
-
- t.boolean :create_package, :default => true
- t.boolean :read_package, :default => true
- t.boolean :edit_package, :default => true
- t.boolean :destroy_package, :default => true
-
- t.boolean :edit_unit, :default => false
-
- t.timestamps
- end
- end
-
- def self.down
- drop_table :memberships
- end
-end
@@ -1,207 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
- <title>Class: Membership [Rails Application Documentation]</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
- <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
- <script type="text/javascript">
- // <![CDATA[
-
- function popupCode( url ) {
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
- }
-
- function toggleCode( id ) {
- if ( document.getElementById )
- elem = document.getElementById( id );
- else if ( document.all )
- elem = eval( "document.all." + id );
- else
- return false;
-
- elemStyle = elem.style;
-
- if ( elemStyle.display != "block" ) {
- elemStyle.display = "block"
- } else {
- elemStyle.display = "none"
- }
-
- return true;
- }
-
- // Make codeblocks hidden by default
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }<\/style>" )
-
- // ]]>
- </script>
-
-</head>
-<body>
-
-
- <div id="classHeader">
- <table class="header-table">
- <tr class="top-aligned-row">
- <td><strong>Class</strong></td>
- <td class="class-name-in-header">Membership</td>
- </tr>
- <tr class="top-aligned-row">
- <td><strong>In:</strong></td>
- <td>
-
-
- <a href="../files/app/models/join_models/membership_rb.html">
-
- app/models/join_models/membership.rb
-
- </a>
-
-
- <br />
-
- </td>
- </tr>
-
-
- <tr class="top-aligned-row">
- <td><strong>Parent:</strong></td>
- <td>
-
- ActiveRecord::Base
-
- </td>
- </tr>
-
- </table>
- </div>
- <!-- banner header -->
-
- <div id="bodyContent">
-
- <div id="contextContent">
-
- </div>
-
-
- <div id="method-list">
- <h3 class="section-bar">Methods</h3>
-
- <div class="name-list">
-
- <a href="#M000074">acls</a>&nbsp;&nbsp;
-
- <a href="#M000075">acls</a>&nbsp;&nbsp;
-
- </div>
- </div>
-
- </div>
-
- <!-- if includes -->
-
- <div id="section">
-
-
-
-
- <!-- if method_list -->
-
- <div id="methods">
-
- <h3 class="section-bar">Public Class methods</h3>
-
-
- <div id="method-M000074" class="method-detail">
- <a name="M000074"></a>
-
- <div class="method-heading">
-
- <a href="#M000074" class="method-signature">
-
- <span class="method-name">acls</span><span class="method-args">()</span>
-
- </a>
-
- </div>
-
- <div class="method-description">
-
- <p>
-Returns a list of ACLs columns in the DB
-</p>
-
- <p><a class="source-toggle" href="#"
- onclick="toggleCode('M000074-source');return false;">[Source]</a></p>
- <div class="method-source-code" id="M000074-source">
-<pre>
- <span class="ruby-comment cmt"># File app/models/join_models/membership.rb, line 6</span>
- 6: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">acls</span>
- 7: <span class="ruby-comment cmt"># Stores attributes that do not represent an ACL</span>
- 8: <span class="ruby-identifier">non_acl_attr</span> = [<span class="ruby-identifier">:id</span>,<span class="ruby-identifier">:unit_id</span>,<span class="ruby-identifier">:updated_at</span>,<span class="ruby-identifier">:user_id</span>,<span class="ruby-identifier">:created_at</span>]
- 9: <span class="ruby-identifier">column_names</span>.<span class="ruby-identifier">collect</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">:to_sym</span>).<span class="ruby-identifier">delete_if</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">non_acl_attr</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">k</span>) }
-10: <span class="ruby-keyword kw">end</span>
-</pre>
- </div>
-
- </div>
- </div>
-
-
- <h3 class="section-bar">Public Instance methods</h3>
-
-
- <div id="method-M000075" class="method-detail">
- <a name="M000075"></a>
-
- <div class="method-heading">
-
- <a href="#M000075" class="method-signature">
-
- <span class="method-name">acls</span><span class="method-args">()</span>
-
- </a>
-
- </div>
-
- <div class="method-description">
-
- <p>
-Return hash of acl attributes (as keys) and their values
-</p>
-
- <p><a class="source-toggle" href="#"
- onclick="toggleCode('M000075-source');return false;">[Source]</a></p>
- <div class="method-source-code" id="M000075-source">
-<pre>
- <span class="ruby-comment cmt"># File app/models/join_models/membership.rb, line 13</span>
-13: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">acls</span>
-14: <span class="ruby-identifier">h</span> = {}
-15: <span class="ruby-constant">Membership</span>.<span class="ruby-identifier">acls</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">acl</span><span class="ruby-operator">|</span>
-16: <span class="ruby-identifier">h</span>[<span class="ruby-identifier">acl</span>] = <span class="ruby-identifier">read_attribute</span>(<span class="ruby-identifier">acl</span>)
-17: <span class="ruby-keyword kw">end</span>
-18: <span class="ruby-identifier">h</span>
-19: <span class="ruby-keyword kw">end</span>
-</pre>
- </div>
-
- </div>
- </div>
-
-
-
- </div>
-
-
-
-
- </div>
-
-<div id="validator-badges">
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
-</div>
-
-</body>
-</html>
Oops, something went wrong.

0 comments on commit 560d3d7

Please sign in to comment.