myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [2783] trunk: Added option for group administrato


From: noreply
Subject: [myexperiment-hackers] [2783] trunk: Added option for group administrators to close their groups to membership requests
Date: Wed, 2 Nov 2011 10:18:05 -0400 (EDT)

Revision
2783
Author
fbacall
Date
2011-11-02 10:18:04 -0400 (Wed, 02 Nov 2011)

Log Message

Added option for group administrators to close their groups to membership requests

Modified Paths

Added Paths

Diff

Modified: trunk/app/controllers/memberships_controller.rb (2782 => 2783)


--- trunk/app/controllers/memberships_controller.rb	2011-11-02 11:49:00 UTC (rev 2782)
+++ trunk/app/controllers/memberships_controller.rb	2011-11-02 14:18:04 UTC (rev 2783)
@@ -155,10 +155,10 @@
       end
       
       respond_to do |format|
+
         if @membership.save
-          
-          # Take into account network's "auto accept" setting
-          if (@membership.network.auto_accept)
+          # Take into account network's new member policy setting
+          if (@membership.network.open?)
             @membership.accept!
             
             begin
@@ -170,7 +170,7 @@
             end
             
             flash[:notice] = 'You have successfully joined the Group.'
-          else
+          elsif (@membership.network.membership_by_request?)
             @membership.user_establish!
             
             begin

Modified: trunk/app/controllers/networks_controller.rb (2782 => 2783)


--- trunk/app/controllers/networks_controller.rb	2011-11-02 11:49:00 UTC (rev 2782)
+++ trunk/app/controllers/networks_controller.rb	2011-11-02 14:18:04 UTC (rev 2783)
@@ -46,9 +46,9 @@
   
   # POST /networks/1;membership_invite
   def membership_invite
-            
-    if (@membership = Membership.new(:user_id => params[:user_id], :network_id => @network.id, :message => params[:membership][:message]) unless Membership.find_by_user_id_and_network_id(params[:user_id], @network.id) or Network.find(@network.id).owner? params[:user_id])
-      
+    @membership = Membership.new(:user_id => params[:user_id], :network_id => @network.id, :message => params[:membership][:message], :invited_by => current_user)
+
+    unless address@hidden || Membership.find_by_user_id_and_network_id(params[:user_id], @network.id) || Network.find(@network.id).owner?(params[:user_id])
       @membership.user_established_at = nil
       @membership.network_established_at = nil
       if @membership.message.blank?
@@ -450,10 +450,11 @@
   end
   
   def find_network_auth_admin
-    begin
-      @network = Network.find(params[:id], :include => [ :owner, :memberships ])
-      raise unless @network.administrator?(current_user.id)
-    rescue ActiveRecord::RecordNotFound
+    if @network = Network.find_by_id(params[:id], :include => [ :owner, :memberships ])
+      unless @network.administrator?(current_user.id)
+        error("You must be a group administrator to invite people","")
+      end
+    else
       error("Group not found (id not authorized)", "is invalid (not owner)")
     end
   end

Modified: trunk/app/models/membership.rb (2782 => 2783)


--- trunk/app/models/membership.rb	2011-11-02 11:49:00 UTC (rev 2782)
+++ trunk/app/models/membership.rb	2011-11-02 14:18:04 UTC (rev 2783)
@@ -8,8 +8,12 @@
 
   belongs_to :network
 
+  belongs_to :invited_by, :class_name => "User", :foreign_key => "inviter_id"
+
   validates_presence_of :user_id, :network_id
 
+  validate :membership_allowed
+
 #  validates_each :user_id do |model, attr, value|
 #    model.errors.add attr, "already member" if model.network.member? value
 #  end
@@ -69,4 +73,13 @@
     end
   end
 
+  private
+
+  def membership_allowed
+    #Can only invite people in a closed group if you're an administrator
+    if self.network.invitation_only? && !self.network.administrators.include?(self.invited_by)
+      errors.add_to_base("This group is not open to membership requests.")
+    end
+  end
+
 end

Modified: trunk/app/models/network.rb (2782 => 2783)


--- trunk/app/models/network.rb	2011-11-02 11:49:00 UTC (rev 2782)
+++ trunk/app/models/network.rb	2011-11-02 14:18:04 UTC (rev 2783)
@@ -182,4 +182,34 @@
     # filter out blogs until they've gone completely
     c.select do |x| x.class != Blog end
   end
+
+  # New member policy
+  # Adapter from #3 of: http://zargony.com/2008/04/28/five-tips-for-developing-rails-applications
+  NEW_MEMBER_POLICY_OPTIONS = [
+                                [:open,"Open to anyone"],
+                                [:by_request,"Membership by request"],
+                                [:invitation_only,"Invitation only"]
+                              ]
+
+  validates_inclusion_of :new_member_policy, :in => NEW_MEMBER_POLICY_OPTIONS.map {|o| o[0]}
+
+  def new_member_policy
+    read_attribute(:new_member_policy).to_sym
+  end
+
+  def new_member_policy=(value)
+    write_attribute(:new_member_policy, value.to_s)
+  end
+
+  def open?
+    new_member_policy == :open
+  end
+
+  def membership_by_request?
+    new_member_policy == :by_request
+  end
+
+  def invitation_only?
+    new_member_policy == :invitation_only
+  end
 end

Modified: trunk/app/views/memberships/new.rhtml (2782 => 2783)


--- trunk/app/views/memberships/new.rhtml	2011-11-02 11:49:00 UTC (rev 2782)
+++ trunk/app/views/memberships/new.rhtml	2011-11-02 14:18:04 UTC (rev 2783)
@@ -1,60 +1,45 @@
 <h1>New Membership Request</h1>
+<div style="margin: auto; width: 500px">
 
-<%= error_messages_for :membership %>
+  <%= error_messages_for :membership %>
 
-<% form_for(:membership, :url ="" user_memberships_path(params[:user_id]), :html => {:id => 'memb_request_form'}) do |f| %>
-	<%= f.hidden_field :user_id, :value => current_user.id %>
+  <% form_for(:membership, :url ="" user_memberships_path(params[:user_id]), :html => {:id => 'memb_request_form'}) do |f| %>
+    <%= f.hidden_field :user_id, :value => current_user.id %>
 
-	<center>
-		<div class="box_standout" style="line-height: 1.6; width: 400px;">
-			<% if params[:network_id] -%>
-				<%= f.hidden_field :network_id, :value => @network.id %>
+    <div class="box_standout">
+      <% if params[:network_id] -%>
+        <%= f.hidden_field :network_id, :value => @network.id %>
 
-				<b>Send a request to join the group:</b>
-				<br/>
-				<%= link_to_function h(@network.title) + expand_image, 
-				                     visual_effect(:toggle_blind, "group_box", :duration => 0.3) -%>
-				 <br/>
-				<small>(Administrator: <%= name @network.user_id -%>)</small>
-			<% else -%>
-				<b>Select group:</b><br/>
-				<%= select_tag "membership[network_id]", options_from_collection_for_select(Network.find(:all, :order => "title ASC"), :id.to_i, :title), :style => "width: 360px; margin-top: 0.3em; margin-bottom: 0.5em" %>
-			<% end -%>
-		</div>
-	</center>
+        <b>Send a request to join the group:</b>
+        <br/>
+        <%= link_to_function h(@network.title) + expand_image,
+                             visual_effect(:toggle_blind, "group_box", :duration => 0.3) -%>
+        <br/>
+        <small>(Administrator: <%= name @network.user_id -%>)</small>
+      <% else -%>
+        <b>Select group:</b><br/>
+        <%= select_tag "membership[network_id]", options_from_collection_for_select(Network.find(:all, :order => "title ASC", :conditions => ["new_member_policy != 'invitation_only'"]), :id.to_i, :title), :style => "width: 360px; margin-top: 0.3em; margin-bottom: 0.5em" %>
+      <% end -%>
+    </div>
 
-	<br/>
+    <div class="box_currentuser_specific" style="margin: 1em 0">
+      <%= info_icon_with_tooltip("This message is optional: if you leave it blank, your request will be sent without it") %>
+      <b>Message to group administrator:</b>
+      <br/>
+      <%= text_area_tag "membership[message]", "", :rows => 4, :style => "width: 370px; font-size: 93%;" -%>
+    </div>
 
-	<center>
-		<div class="box_currentuser_specific" style="text-align: center; width: 400px; font-size: 93%; padding-bottom: 1em;">
-			<center>
-				<table>
-					<tr>
-						<td style="line-height: 2; text-align: left;">
-							<%= info_icon_with_tooltip("This message is optional: if you leave it blank, your request will be sent without it") %>
-							<b>Message to group administrator:</b>
-							<br/>
-							<%= text_area_tag "membership[message]", "", :rows => 4, :style => "width: 370px; font-size: 93%;" -%>
-						</td>
-					</tr>
-				</table>
-			</center>
-		</div>
-	</center>
+    <div style="text-align: center">
+      <%= submit_tag "Send membership request", :id => "send", :style => 'width: 180px;', : "$('cancel').disabled=true;this.disabled=true;this.value='Sending your request...';this.form.submit();"  %>
+      <% cancel_links_to = params[:network_id] ? url_for(:controller => 'networks', :action ="" 'show', :id => @network.id) : url_for(:controller => 'networks', :action ="" 'index') %>
+      <input type="submit" id="cancel" value="Return to Group" style="width: 180px"  cancel_links_to -%>';return false;" />
+    </div>
 
-	<br/>
+    <% if params[:network_id] -%>
+      <div id="group_box" style="display: none; margin-top: 3em;">
+        <%= render :partial => "networks/table", :locals => { :collection => [ @network ] } %>
+      </div>
+    <% end %>
 
-	<center>
-		<%= submit_tag "Send membership request", :id => "send", :style => 'width: 180px;', : "$('cancel').disabled=true;this.disabled=true;this.value='Sending your request...';this.form.submit();"  %>
-
-		<% cancel_links_to = params[:network_id] ? url_for(:controller => 'networks', :action ="" 'show', :id => @network.id) : url_for(:controller => 'networks', :action ="" 'index') %>
-		<input type="submit" id="cancel" value="Return to Group" style="width: 180px"  cancel_links_to -%>';return false;" />
-	</center>
-
-	<% if params[:network_id] -%>
-		<div id="group_box" style="display: none; margin-top: 3em;">
-			<%= render :partial => "networks/table", :locals => { :collection => [ @network ] } %>
-		</div>
-	<% end %>
-
-<% end %>
+  <% end %>
+</div>

Modified: trunk/app/views/networks/_form.rhtml (2782 => 2783)


--- trunk/app/views/networks/_form.rhtml	2011-11-02 11:49:00 UTC (rev 2782)
+++ trunk/app/views/networks/_form.rhtml	2011-11-02 14:18:04 UTC (rev 2783)
@@ -29,13 +29,12 @@
   </fieldset>
 
   <fieldset>
-    <legend>Auto Accept Join Requests</legend>
+    <legend>New Membership Policy</legend>
     <p>
-    	You can configure this group to automatically accept requests from users to join.
+    	You can specify a policy on how new members can join this group.
 		</p>
     <p>
-      <%= form.check_box :auto_accept %>
-      <b>Auto Accept Join Requests</b><br />
+      <%= form.select :new_member_policy, Network::NEW_MEMBER_POLICY_OPTIONS.map {|o| [o[1],o[0]]} %>
     </p>
   </fieldset>
   

Modified: trunk/app/views/networks/_table.rhtml (2782 => 2783)


--- trunk/app/views/networks/_table.rhtml	2011-11-02 11:49:00 UTC (rev 2782)
+++ trunk/app/views/networks/_table.rhtml	2011-11-02 14:18:04 UTC (rev 2783)
@@ -76,7 +76,7 @@
 			          <% if cur_membership %>
 			            <%= icon('network-leave', membership_path(cur_membership.user_id, cur_membership) + "?return_to=" + groups_path, nil, { :confirm => "Are you sure want to leave this group?", :method => :delete }, 'Leave Group') %>
 			          <% end %>
-							<% elsif !current_user.membership_pending?(network.id) %>
+							<% elsif !current_user.membership_pending?(network.id) && !network.invitation_only? %>
 							  <!-- not an admin, not a member yet and hasn't got pending request -->
 								<%= request_membership_link(current_user.id, network.id) %>
 							<% end %>

Modified: trunk/app/views/networks/invite.rhtml (2782 => 2783)


--- trunk/app/views/networks/invite.rhtml	2011-11-02 11:49:00 UTC (rev 2782)
+++ trunk/app/views/networks/invite.rhtml	2011-11-02 14:18:04 UTC (rev 2783)
@@ -4,86 +4,93 @@
   Here you can invite users to this group. The options are:<br/>
 </p>
 
-<% # choose, which of the DIVs will be shown & which radio button ticked -%>
-<% # on first load, has default value -%>
+<%# choose, which of the DIVs will be shown & which radio button ticked -%>
+<%# on first load, has default value -%>
 <% invite_existing_selected = invite_existing_selected?(params[:radio_choice]) -%>
 
-<label for="" radio_button_tag ("radio_invite", "existing", invite_existing_selected, : "$('radio_invite_new').checked=false;$('div_invite_existing').show();$('div_invite_new').hide();return true;" ) -%>Invite an existing <%= Conf.sitename %> user to your group</label><br/>
-<label for="" style="margin-top: 0.3em;"><%= radio_button_tag ("radio_invite", "new", !invite_existing_selected, : "$('radio_invite_existing').checked=false;$('div_invite_existing').hide();$('div_invite_new').show();return true;" ) -%>Invite someone to join <%= Conf.sitename %> and your group</label>
+<label for=""
+  <%= radio_button_tag ("radio_invite", "existing", invite_existing_selected, : "$('radio_invite_new').checked=false;$('div_invite_existing').show();$('div_invite_new').hide();return true;" ) -%>
+  Invite an existing <%= Conf.sitename %> user to your group
+</label>
+<br/>
+<label for=""
+  <%= radio_button_tag ("radio_invite", "new", !invite_existing_selected, : "$('radio_invite_existing').checked=false;$('div_invite_existing').hide();$('div_invite_new').show();return true;" ) -%>
+  Invite someone to join <%= Conf.sitename -%> and your group
+</label>
 
-<% # just one from the two of following DIVs will be shown at any one time; -%>
-<% # this represents one of two options - either to invite existing or new users to the group -%>
+<%# just one from the two of following DIVs will be shown at any one time; -%>
+<%# this represents one of two options - either to invite existing or new users to the group -%>
 
 <div id="div_invite_existing" class="box_editing" style="<%= !invite_existing_selected ? "display: none;" : "" -%>margin: 1em 0em 1em 0em;">
   <fieldset>
-  	<legend>Invite an existing <%= Conf.sitename %> user to your group</legend>
-	  <p class="box_infotext" style="margin: 0.4em 0em 0.7em 0em" >
+    <legend>Invite an existing <%= Conf.sitename %> user to your group</legend>
+    <p class="box_infotext" style="margin: 0.4em 0em 0.7em 0em" >
       Select a name from the list, type in a message to the user and click "Invite".
     </p>
 
     <% form_tag(membership_invite_group_path(@network), :method => :post) do %>
       <table cellpadding="0" cellspacing="0">
-			<tr>
-				<td>&nbsp;</td>
-				<td style="text-align: left;">User:</td>
-			  <td style="text-align: left;"><%= select_tag :user_id, options_from_collection_for_select(User.find(:all, :order => "name ASC"), :id.to_i, :name), :style => "width: 400px;" -%></td>
-			</tr>
-			<tr style="vertical-align: top;">
-				<td><%= info_icon_with_tooltip("This message is optional: if you leave it blank, your invitation will be sent without it") -%></td>
-				<td style="text-align: left;">Message:</td>
-				<td style="text-align: left;"><%= text_area_tag "membership[message]", "", :rows => 4, :style => "width: 400px" -%></td>
-      </tr>
-			<tr>
-				<td colspan="3" style="text-align: center;"><%= submit_tag "Send Invitation", :disable_with => 'Sending Invitation...' %></td>
-			</tr>
-			</table>		  		
-		<% end %>
-	</fieldset>
+        <tr>
+          <td>&nbsp;</td>
+          <td style="text-align: left;">User:</td>
+          <td style="text-align: left;"><%= select_tag :user_id, options_from_collection_for_select(User.find(:all, :order => "name ASC"), :id.to_i, :name), :style => "width: 400px;" -%></td>
+        </tr>
+        <tr style="vertical-align: top;">
+          <td><%= info_icon_with_tooltip("This message is optional: if you leave it blank, your invitation will be sent without it") -%></td>
+          <td style="text-align: left;">Message:</td>
+          <td style="text-align: left;"><%= text_area_tag "membership[message]", "", :rows => 4, :style => "width: 400px" -%></td>
+        </tr>
+        <tr>
+          <td colspan="3" style="text-align: center;"><%= submit_tag "Send Invitation", :disable_with => 'Sending Invitation...' %></td>
+        </tr>
+      </table>
+    <% end %>
+  </fieldset>
 </div>
 
 <div id="div_invite_new" class="box_editing" style="<%= invite_existing_selected ? "display: none;" : "" -%>margin: 1em 0em 1em 0em;">
-	<fieldset>
-  	<legend>Invite someone to join <%= Conf.sitename %> and your group</legend>
-	  <p class="box_infotext" style="margin: 0.4em 0em 1em 0em" >
+  <fieldset>
+    <legend>Invite someone to join <%= Conf.sitename %> and your group</legend>
+    <p class="box_infotext" style="margin: 0.4em 0em 1em 0em" >
       Type in email addresses you want to send invitations to, personal message to new users and click "Invite".
     </p>
-		
-		<% form_tag (membership_invite_external_group_path(@network), :method => :post) do %>
-		  <%= hidden_field_tag "radio_choice", "" -%>
-			<table>
-		  	<tr>
-		  		<td style="text-align: left;">
-					  <% remaining_allowance, allowance_finishes = ActivityLimit.remaining_allowance(current_user, "group_invite") -%>
-			      <%= info_icon_with_tooltip("To include several email addresses, use commas or semicolons to separate them.<br/>#{remaining_allowance ? "Please note that your current allowance is to send invitations to #{remaining_allowance} unique, valid, non-blank address(es) in the list; the allowance #{allowance_finishes ? "will be renewed after #{allowance_finishes.strftime("%H:%M on %d/%m/%Y")}" : "will not be reset"}." : "Please note that limitations on the number of invitations to be sent may apply."}") %>
+
+    <% form_tag (membership_invite_external_group_path(@network), :method => :post) do %>
+      <%= hidden_field_tag "radio_choice", "" -%>
+      <table>
+        <tr>
+          <td style="text-align: left;">
+            <% remaining_allowance, allowance_finishes = ActivityLimit.remaining_allowance(current_user, "group_invite") -%>
+            <%= info_icon_with_tooltip("To include several email addresses, use commas or semicolons to separate them.<br/>#{remaining_allowance ? "Please note that your current allowance is to send invitations to #{remaining_allowance} unique, valid, non-blank address(es) in the list; the allowance #{allowance_finishes ? "will be renewed after #{allowance_finishes.strftime("%H:%M on %d/%m/%Y")}" : "will not be reset"}." : "Please note that limitations on the number of invitations to be sent may apply."}") %>
             Email address(es) to send invitations to:<br/>
             <% email_addresses_val = ((params[:invitations].nil? || params[:invitations][:address_list].nil?) ? "" : params[:invitations][:address_list]) %>
             <%= text_field_tag "invitations[address_list]", email_addresses_val, :style => "width: 500px; margin-bottom: 0.8em;" -%><br/>
-            
+
             <%= info_icon_with_tooltip("This message is optional: if you leave it blank, default one will be sent") %>
             Personal message to include with the invitation(s):<br/>
             <% msg_text_val = ((params[:invitations].nil? || params[:invitations][:msg_text].nil?) ? "" : params[:invitations][:msg_text]) %>
             <%= text_area_tag "invitations[msg_text]", msg_text_val, :rows => 4, :style => "width: 500px" -%><br/>
-          
-					  <table style="margin-top: 1.5em;">
-							<tr>
-								<td>
-						      <% c = prepare_captcha :type => :image -%>
-									<%= captcha_image_tag c -%>
-								</td>
-								<td style="vertical-align: middle;">
-								  <%= captcha_hidden_field c, 'invitations' -%>
-									<%= captcha_label 'invitations', 'Type in the text from the image on the left:' -%><br/>
-					        <%= captcha_text_field 'invitations', :size => 40 -%>
-								</td>
-							</tr>
-						</table>
-					</td>
-			  </tr>
-			  <tr>
-			  	<td style="text-align: center;"><%= submit_tag "Send Invitations", :id => "send_button", : "if($('invitations[address_list]').value=='') { alert('Please enter email address(es) that you want to send user invitations to.');$('invitations[address_list]').focus();return(false); } else { $('radio_choice').value=($('radio_invite_existing').checked ? 'existing' : 'new');this.disabled=true;this.value='Sending...';this.form.submit(); }" -%></td>
-				</tr>
-			</table>
-		<% end %>
-		
-		</fieldset>
+
+            <table style="margin-top: 1.5em;">
+              <tr>
+                <td>
+                  <% c = prepare_captcha :type => :image -%>
+                  <%= captcha_image_tag c -%>
+                </td>
+                <td style="vertical-align: middle;">
+                  <%= captcha_hidden_field c, 'invitations' -%>
+                  <%= captcha_label 'invitations', 'Type in the text from the image on the left:' -%><br/>
+                  <%= captcha_text_field 'invitations', :size => 40 -%>
+                </td>
+              </tr>
+            </table>
+          </td>
+        </tr>
+        <tr>
+          <td style="text-align: center;"><%= submit_tag "Send Invitations", :id => "send_button", : "if($('invitations[address_list]').value=='') { alert('Please enter email address(es) that you want to send user invitations to.');$('invitations[address_list]').focus();return(false); } else { $('radio_choice').value=($('radio_invite_existing').checked ? 'existing' : 'new');this.disabled=true;this.value='Sending...';this.form.submit(); }" -%></td>
+        </tr>
+      </table>
+    <% end %>
+
+  </fieldset>
 </div>

Modified: trunk/app/views/networks/show.rhtml (2782 => 2783)


--- trunk/app/views/networks/show.rhtml	2011-11-02 11:49:00 UTC (rev 2782)
+++ trunk/app/views/networks/show.rhtml	2011-11-02 14:18:04 UTC (rev 2783)
@@ -10,9 +10,7 @@
 				<span style="text-align: left;"><b>You have been invited to join this group. Awaiting your <%= link_to "confirmation", membership_path(current_user, Membership.find(:first, :conditions => ['network_id = ? AND user_id = ?', @network, current_user])) -%>.</b></span>
 			</div>
 		<% end %>
-	<% end %>
 
-<% if logged_in? %>
   <ul class="sectionIcons">
     <% unless mine? @network %>
 		  <% if @network.member? current_user.id  %>
@@ -20,7 +18,7 @@
 			  <% if cur_membership %>
 			    <li><%= icon('network-leave', membership_path(cur_membership.user_id, cur_membership), nil, { :confirm => "Are you sure want to leave this group?", :method => :delete }, 'Leave Group') %></li>
 			  <% end %>
-			<% elsif !current_user.membership_pending?(@network.id) %>
+			<% elsif !current_user.membership_pending?(@network.id) && address@hidden %>
 			  <li class="with_sep_bottom"><%= request_membership_link(current_user.id, @network.id) %></li>  
 			<% end %>
 		<% end %>
@@ -96,10 +94,12 @@
 	<% if mine? @network %>
 		<br/>
 		<div class="box_currentuser_specific">
-			<% if @network.auto_accept %>
-				You have set this Group to automatically accept all Membership Requests
-			<% else %>
-				You have set this Group to send you all Membership Requests for confirmation first
+			<% if @network.open? %>
+				You have set this Group to automatically accept all membership requests.
+			<% elsif @network.membership_by_request? %>
+				You have set this Group to require membership requests to be approved by a group administrator.
+      <% else %>
+        You have set this Group to be closed to membership requests unless invited by a group administrator.
 			<% end %>
 		</div>
 	<% end %>
@@ -118,7 +118,6 @@
 		</div>
 		<p class="heading">
 			Members
-			<a name="group_members"></a>
 		</p>
 		<div>
 			<%= render :partial => "networks/members", :locals => { :collection => others, :size => 60 } %>

Added: trunk/db/migrate/092_add_new_member_policy_to_networks.rb (0 => 2783)


--- trunk/db/migrate/092_add_new_member_policy_to_networks.rb	                        (rev 0)
+++ trunk/db/migrate/092_add_new_member_policy_to_networks.rb	2011-11-02 14:18:04 UTC (rev 2783)
@@ -0,0 +1,32 @@
+class AddNewMemberPolicyToNetworks < ActiveRecord::Migration
+  def self.up
+    add_column :networks, :new_member_policy, :string, :default => "open"
+
+    Network.find(:all).each do |n|
+      if n.attributes["auto_accept"] == true
+        n.new_member_policy = :open
+      else
+        n.new_member_policy = :by_request
+      end
+      n.save
+    end
+
+    remove_column :networks, :auto_accept
+  end
+
+  #Will lose info on whether a network is invite only
+  def self.down
+    add_column :networks, :auto_accept, :boolean, :default => false
+
+    Network.find(:all).each do |n|
+      if n.attributes["new_member_policy"] == "open"
+        n.auto_accept = true
+      else
+        n.auto_accept = false
+      end
+      n.save
+    end
+
+    remove_column :networks, :new_member_policy
+  end
+end

Added: trunk/db/migrate/093_add_invited_by_to_memberships.rb (0 => 2783)


--- trunk/db/migrate/093_add_invited_by_to_memberships.rb	                        (rev 0)
+++ trunk/db/migrate/093_add_invited_by_to_memberships.rb	2011-11-02 14:18:04 UTC (rev 2783)
@@ -0,0 +1,9 @@
+class AddInvitedByToMemberships < ActiveRecord::Migration
+  def self.up
+    add_column :networks, :inviter_id, :integer
+  end
+
+  def self.down
+    remove_column :networks, :inviter_id
+  end
+end

Added: trunk/db/schema.rb (0 => 2783)


--- trunk/db/schema.rb	                        (rev 0)
+++ trunk/db/schema.rb	2011-11-02 14:18:04 UTC (rev 2783)
@@ -0,0 +1,803 @@
+# This file is autogenerated. Instead of editing this file, please use the
+# migrations feature of ActiveRecord to incrementally modify your database, and
+# then regenerate this schema definition.
+
+ActiveRecord::Schema.define(:version => 93) do
+
+  create_table "activity_limits", :force => true do |t|
+    t.column "contributor_type", :string,   :null => false
+    t.column "contributor_id",   :integer,  :null => false
+    t.column "limit_feature",    :string,   :null => false
+    t.column "limit_max",        :integer
+    t.column "limit_frequency",  :integer
+    t.column "current_count",    :integer,  :null => false
+    t.column "reset_after",      :datetime
+    t.column "promote_after",    :datetime
+  end
+
+  create_table "announcements", :force => true do |t|
+    t.column "title",      :string
+    t.column "user_id",    :integer
+    t.column "created_at", :datetime
+    t.column "updated_at", :datetime
+    t.column "body",       :text
+    t.column "body_html",  :text
+  end
+
+  create_table "attributions", :force => true do |t|
+    t.column "attributor_id",     :integer
+    t.column "attributor_type",   :string
+    t.column "attributable_id",   :integer
+    t.column "attributable_type", :string
+    t.column "created_at",        :datetime
+    t.column "updated_at",        :datetime
+  end
+
+  create_table "auto_tables", :force => true do |t|
+    t.column "name",   :string
+    t.column "schema", :text
+  end
+
+  create_table "blobs", :force => true do |t|
+    t.column "local_name",       :string
+    t.column "contributor_id",   :integer
+    t.column "body_html",        :text
+    t.column "created_at",       :datetime
+    t.column "body",             :text
+    t.column "title",            :string
+    t.column "content_blob_id",  :integer
+    t.column "updated_at",       :datetime
+    t.column "license_id",       :integer
+    t.column "content_type_id",  :integer
+    t.column "contributor_type", :string
+  end
+
+  create_table "blog_posts", :force => true do |t|
+    t.column "blog_id",    :integer
+    t.column "title",      :string
+    t.column "body",       :text
+    t.column "created_at", :datetime
+    t.column "updated_at", :datetime
+    t.column "body_html",  :text
+  end
+
+  create_table "blogs", :force => true do |t|
+    t.column "contributor_id",   :integer
+    t.column "contributor_type", :string
+    t.column "title",            :string
+    t.column "created_at",       :datetime
+    t.column "updated_at",       :datetime
+  end
+
+  create_table "bookmarks", :force => true do |t|
+    t.column "title",             :string,   :limit => 50, :default => ""
+    t.column "created_at",        :datetime,                               :null => false
+    t.column "bookmarkable_type", :string,   :limit => 15, :default => "", :null => false
+    t.column "bookmarkable_id",   :integer,                :default => 0,  :null => false
+    t.column "user_id",           :integer,                :default => 0,  :null => false
+  end
+
+  add_index "bookmarks", ["user_id"], :name => "index_bookmarks_on_user_id"
+
+  create_table "citations", :force => true do |t|
+    t.column "user_id",          :integer
+    t.column "workflow_id",      :integer
+    t.column "workflow_version", :integer
+    t.column "authors",          :text
+    t.column "title",            :string
+    t.column "publication",      :string
+    t.column "published_at",     :datetime
+    t.column "accessed_at",      :datetime
+    t.column "url",              :string
+    t.column "isbn",             :string
+    t.column "issn",             :string
+    t.column "created_at",       :datetime
+    t.column "updated_at",       :datetime
+  end
+
+  create_table "client_applications", :force => true do |t|
+    t.column "name",         :string
+    t.column "url",          :string
+    t.column "support_url",  :string
+    t.column "callback_url", :string
+    t.column "key",          :string,   :limit => 50
+    t.column "secret",       :string,   :limit => 50
+    t.column "user_id",      :integer
+    t.column "key_type",     :string
+    t.column "created_at",   :datetime
+    t.column "updated_at",   :datetime
+    t.column "creator_id",   :integer
+  end
+
+  add_index "client_applications", ["key"], :name => "index_client_applications_on_key", :unique => true
+
+  create_table "comments", :force => true do |t|
+    t.column "comment",          :text
+    t.column "created_at",       :datetime,                               :null => false
+    t.column "commentable_id",   :integer,                :default => 0,  :null => false
+    t.column "commentable_type", :string,   :limit => 15, :default => "", :null => false
+    t.column "user_id",          :integer,                :default => 0,  :null => false
+  end
+
+  add_index "comments", ["user_id"], :name => "index_comments_on_user_id"
+
+  create_table "concept_relations", :force => true do |t|
+    t.column "subject_concept_id", :integer
+    t.column "relation_type",      :string
+    t.column "object_concept_id",  :integer
+  end
+
+  create_table "concepts", :force => true do |t|
+    t.column "vocabulary_id",    :integer
+    t.column "created_at",       :datetime
+    t.column "description_html", :text
+    t.column "updated_at",       :datetime
+    t.column "phrase",           :string
+    t.column "description",      :text
+  end
+
+  create_table "content_blobs", :force => true do |t|
+    t.column "data", :binary
+  end
+
+  create_table "content_types", :force => true do |t|
+    t.column "created_at",       :datetime
+    t.column "category",         :string
+    t.column "description_html", :text
+    t.column "title",            :string
+    t.column "updated_at",       :datetime
+    t.column "mime_type",        :string
+    t.column "user_id",          :integer
+    t.column "description",      :text
+  end
+
+  create_table "contributions", :force => true do |t|
+    t.column "label",                :string
+    t.column "rating",               :float
+    t.column "contributable_type",   :string
+    t.column "contributor_id",       :integer
+    t.column "created_at",           :datetime
+    t.column "policy_id",            :integer
+    t.column "updated_at",           :datetime
+    t.column "license_id",           :integer
+    t.column "rank",                 :float
+    t.column "content_type_id",      :integer
+    t.column "site_downloads_count", :integer,  :default => 0
+    t.column "viewings_count",       :integer,  :default => 0
+    t.column "contributor_type",     :string
+    t.column "downloads_count",      :integer,  :default => 0
+    t.column "site_viewings_count",  :integer,  :default => 0
+    t.column "contributable_id",     :integer
+  end
+
+  add_index "contributions", ["contributable_id", "contributable_type"], :name => "index_contributions_on_contributable_id_and_contributable_type"
+  add_index "contributions", ["contributor_id", "contributor_type"], :name => "index_contributions_on_contributor_id_and_contributor_type"
+
+  create_table "creditations", :force => true do |t|
+    t.column "creditor_id",     :integer
+    t.column "creditor_type",   :string
+    t.column "creditable_id",   :integer
+    t.column "creditable_type", :string
+    t.column "created_at",      :datetime
+    t.column "updated_at",      :datetime
+  end
+
+  create_table "curation_events", :force => true do |t|
+    t.column "user_id",      :integer
+    t.column "category",     :string
+    t.column "object_type",  :string
+    t.column "object_id",    :integer
+    t.column "details",      :text
+    t.column "details_html", :text
+    t.column "created_at",   :datetime
+    t.column "updated_at",   :datetime
+  end
+
+  create_table "downloads", :force => true do |t|
+    t.column "kind",               :string
+    t.column "created_at",         :datetime
+    t.column "accessed_from_site", :boolean,  :default => false
+    t.column "user_id",            :integer
+    t.column "user_agent",         :string
+    t.column "contribution_id",    :integer
+  end
+
+  add_index "downloads", ["contribution_id"], :name => "index_downloads_on_contribution_id"
+
+  create_table "experiments", :force => true do |t|
+    t.column "title",            :string
+    t.column "description",      :text
+    t.column "description_html", :text
+    t.column "contributor_id",   :integer
+    t.column "contributor_type", :string
+    t.column "created_at",       :datetime
+    t.column "updated_at",       :datetime
+  end
+
+  create_table "federation_sources", :force => true do |t|
+    t.column "name", :string
+  end
+
+  create_table "friendships", :force => true do |t|
+    t.column "user_id",     :integer
+    t.column "friend_id",   :integer
+    t.column "created_at",  :datetime
+    t.column "accepted_at", :datetime
+    t.column "message",     :string,   :limit => 500
+  end
+
+  add_index "friendships", ["friend_id"], :name => "index_friendships_on_friend_id"
+  add_index "friendships", ["user_id"], :name => "index_friendships_on_user_id"
+
+  create_table "group_announcements", :force => true do |t|
+    t.column "title",      :string
+    t.column "network_id", :integer
+    t.column "user_id",    :integer
+    t.column "public",     :boolean,  :default => false
+    t.column "created_at", :datetime
+    t.column "updated_at", :datetime
+    t.column "body",       :text
+    t.column "body_html",  :text
+  end
+
+  create_table "jobs", :force => true do |t|
+    t.column "title",            :string
+    t.column "description",      :text
+    t.column "description_html", :text
+    t.column "experiment_id",    :integer
+    t.column "user_id",          :integer
+    t.column "runnable_id",      :integer
+    t.column "runnable_version", :integer
+    t.column "runnable_type",    :string
+    t.column "runner_id",        :integer
+    t.column "runner_type",      :string
+    t.column "submitted_at",     :datetime
+    t.column "started_at",       :datetime
+    t.column "completed_at",     :datetime
+    t.column "last_status",      :string
+    t.column "last_status_at",   :datetime
+    t.column "job_uri",          :string
+    t.column "job_manifest",     :binary
+    t.column "inputs_uri",       :string
+    t.column "inputs_data",      :binary
+    t.column "outputs_uri",      :string
+    t.column "created_at",       :datetime
+    t.column "updated_at",       :datetime
+    t.column "parent_job_id",    :integer
+  end
+
+  create_table "key_permissions", :force => true do |t|
+    t.column "client_application_id", :integer
+    t.column "for",                   :string
+  end
+
+  create_table "labels", :force => true do |t|
+    t.column "vocabulary_id", :integer
+    t.column "language",      :string
+    t.column "text",          :string
+    t.column "label_type",    :string
+    t.column "concept_id",    :integer
+  end
+
+  create_table "license_attributes", :force => true do |t|
+    t.column "license_id",        :integer
+    t.column "license_option_id", :integer
+    t.column "created_at",        :datetime
+  end
+
+  create_table "license_options", :force => true do |t|
+    t.column "user_id",          :integer
+    t.column "title",            :string
+    t.column "description",      :text
+    t.column "description_html", :text
+    t.column "uri",              :string
+    t.column "predicate",        :string
+    t.column "created_at",       :datetime
+    t.column "updated_at",       :datetime
+  end
+
+  create_table "licenses", :force => true do |t|
+    t.column "user_id",          :integer
+    t.column "unique_name",      :string
+    t.column "title",            :string
+    t.column "description",      :text
+    t.column "description_html", :text
+    t.column "url",              :string
+    t.column "created_at",       :datetime
+    t.column "updated_at",       :datetime
+  end
+
+  create_table "memberships", :force => true do |t|
+    t.column "user_id",                :integer
+    t.column "network_id",             :integer
+    t.column "created_at",             :datetime
+    t.column "user_established_at",    :datetime
+    t.column "network_established_at", :datetime
+    t.column "message",                :string,   :limit => 500
+    t.column "administrator",          :boolean,                 :default => false
+  end
+
+  add_index "memberships", ["network_id"], :name => "index_memberships_on_network_id"
+  add_index "memberships", ["user_id"], :name => "index_memberships_on_user_id"
+
+  create_table "messages", :force => true do |t|
+    t.column "from",                 :integer
+    t.column "to",                   :integer
+    t.column "subject",              :string
+    t.column "body",                 :text
+    t.column "reply_id",             :integer
+    t.column "created_at",           :datetime
+    t.column "read_at",              :datetime
+    t.column "body_html",            :text
+    t.column "deleted_by_sender",    :boolean,  :default => false
+    t.column "deleted_by_recipient", :boolean,  :default => false
+  end
+
+  create_table "networks", :force => true do |t|
+    t.column "user_id",           :integer
+    t.column "title",             :string
+    t.column "unique_name",       :string
+    t.column "created_at",        :datetime
+    t.column "updated_at",        :datetime
+    t.column "description",       :text
+    t.column "description_html",  :text
+    t.column "new_member_policy", :string,   :default => "open"
+    t.column "inviter_id",        :integer
+  end
+
+  add_index "networks", ["user_id"], :name => "index_networks_on_user_id"
+
+  create_table "oauth_nonces", :force => true do |t|
+    t.column "nonce",      :string
+    t.column "timestamp",  :integer
+    t.column "created_at", :datetime
+    t.column "updated_at", :datetime
+  end
+
+  add_index "oauth_nonces", ["nonce", "timestamp"], :name => "index_oauth_nonces_on_nonce_and_timestamp", :unique => true
+
+  create_table "oauth_tokens", :force => true do |t|
+    t.column "user_id",               :integer
+    t.column "type",                  :string,   :limit => 20
+    t.column "client_application_id", :integer
+    t.column "token",                 :string,   :limit => 50
+    t.column "secret",                :string,   :limit => 50
+    t.column "authorized_at",         :datetime
+    t.column "invalidated_at",        :datetime
+    t.column "created_at",            :datetime
+    t.column "updated_at",            :datetime
+  end
+
+  add_index "oauth_tokens", ["token"], :name => "index_oauth_tokens_on_token", :unique => true
+
+  create_table "ontologies", :force => true do |t|
+    t.column "created_at",       :datetime
+    t.column "description_html", :text
+    t.column "uri",              :string
+    t.column "prefix",           :string
+    t.column "title",            :string
+    t.column "updated_at",       :datetime
+    t.column "user_id",          :integer
+    t.column "description",      :text
+  end
+
+  create_table "pack_contributable_entries", :force => true do |t|
+    t.column "comment",               :text
+    t.column "contributable_type",    :string
+    t.column "contributable_version", :integer
+    t.column "created_at",            :datetime
+    t.column "updated_at",            :datetime
+    t.column "pack_id",               :integer,  :null => false
+    t.column "user_id",               :integer,  :null => false
+    t.column "contributable_id",      :integer,  :null => false
+  end
+
+  create_table "pack_remote_entries", :force => true do |t|
+    t.column "comment",       :text
+    t.column "created_at",    :datetime
+    t.column "uri",           :string
+    t.column "title",         :string
+    t.column "updated_at",    :datetime
+    t.column "pack_id",       :integer,  :null => false
+    t.column "user_id",       :integer,  :null => false
+    t.column "alternate_uri", :string
+  end
+
+  create_table "packs", :force => true do |t|
+    t.column "contributor_id",   :integer
+    t.column "created_at",       :datetime
+    t.column "description_html", :text
+    t.column "title",            :string
+    t.column "updated_at",       :datetime
+    t.column "description",      :text
+    t.column "contributor_type", :string
+  end
+
+  create_table "pending_invitations", :force => true do |t|
+    t.column "email",        :string
+    t.column "created_at",   :datetime
+    t.column "request_type", :string
+    t.column "requested_by", :integer
+    t.column "request_for",  :integer
+    t.column "message",      :string,   :limit => 500
+    t.column "token",        :string
+  end
+
+  create_table "permissions", :force => true do |t|
+    t.column "contributor_id",   :integer
+    t.column "contributor_type", :string
+    t.column "policy_id",        :integer
+    t.column "download",         :boolean,  :default => false
+    t.column "edit",             :boolean,  :default => false
+    t.column "view",             :boolean,  :default => false
+    t.column "created_at",       :datetime
+    t.column "updated_at",       :datetime
+  end
+
+  add_index "permissions", ["policy_id"], :name => "index_permissions_on_policy_id"
+
+  create_table "picture_selections", :force => true do |t|
+    t.column "user_id",    :integer
+    t.column "picture_id", :integer
+    t.column "created_at", :datetime
+  end
+
+  create_table "pictures", :force => true do |t|
+    t.column "data",    :binary
+    t.column "user_id", :integer
+  end
+
+  create_table "policies", :force => true do |t|
+    t.column "name",             :string
+    t.column "contributor_id",   :integer
+    t.column "created_at",       :datetime
+    t.column "updated_at",       :datetime
+    t.column "update_mode",      :integer
+    t.column "share_mode",       :integer
+    t.column "contributor_type", :string
+    t.column "public_view",      :boolean,  :default => false
+    t.column "public_download",  :boolean,  :default => false
+  end
+
+  create_table "predicates", :force => true do |t|
+    t.column "created_at",       :datetime
+    t.column "description_html", :text
+    t.column "title",            :string
+    t.column "ontology_id",      :integer
+    t.column "updated_at",       :datetime
+    t.column "phrase",           :string
+    t.column "equivalent_to",    :text
+    t.column "description",      :text
+  end
+
+  create_table "previews", :force => true do |t|
+    t.column "created_at",    :datetime
+    t.column "svg_blob_id",   :integer
+    t.column "image_blob_id", :integer
+  end
+
+  create_table "profiles", :force => true do |t|
+    t.column "user_id",             :integer
+    t.column "picture_id",          :integer
+    t.column "email",               :string
+    t.column "website",             :string
+    t.column "created_at",          :datetime
+    t.column "updated_at",          :datetime
+    t.column "body",                :text
+    t.column "body_html",           :text
+    t.column "field_or_industry",   :string
+    t.column "occupation_or_roles", :string
+    t.column "organisations",       :text
+    t.column "location_city",       :string
+    t.column "location_country",    :string
+    t.column "interests",           :text
+    t.column "contact_details",     :text
+  end
+
+  add_index "profiles", ["user_id"], :name => "index_profiles_on_user_id"
+
+  create_table "ratings", :force => true do |t|
+    t.column "rating",        :integer,                :default => 0
+    t.column "created_at",    :datetime,                               :null => false
+    t.column "rateable_type", :string,   :limit => 15, :default => "", :null => false
+    t.column "rateable_id",   :integer,                :default => 0,  :null => false
+    t.column "user_id",       :integer,                :default => 0,  :null => false
+  end
+
+  add_index "ratings", ["user_id"], :name => "index_ratings_on_user_id"
+
+  create_table "relationships", :force => true do |t|
+    t.column "context_id",   :integer
+    t.column "created_at",   :datetime
+    t.column "context_type", :string
+    t.column "objekt_type",  :string
+    t.column "objekt_id",    :integer
+    t.column "subject_id",   :integer
+    t.column "predicate_id", :integer
+    t.column "subject_type", :string
+    t.column "user_id",      :integer
+  end
+
+  create_table "remote_workflows", :force => true do |t|
+    t.column "workflow_id",        :integer
+    t.column "workflow_version",   :integer
+    t.column "taverna_enactor_id", :integer
+    t.column "workflow_uri",       :string
+  end
+
+  create_table "reviews", :force => true do |t|
+    t.column "title",           :string,                 :default => ""
+    t.column "review",          :text
+    t.column "created_at",      :datetime,                               :null => false
+    t.column "updated_at",      :datetime,                               :null => false
+    t.column "reviewable_id",   :integer,                :default => 0,  :null => false
+    t.column "reviewable_type", :string,   :limit => 15, :default => "", :null => false
+    t.column "user_id",         :integer,                :default => 0,  :null => false
+  end
+
+  add_index "reviews", ["user_id"], :name => "index_reviews_on_user_id"
+
+  create_table "service_categories", :force => true do |t|
+    t.column "label",        :string
+    t.column "uri",          :string
+    t.column "retrieved_at", :datetime
+    t.column "created_at",   :datetime
+    t.column "updated_at",   :datetime
+    t.column "service_id",   :integer
+  end
+
+  create_table "service_deployments", :force => true do |t|
+    t.column "service_provider_id",  :integer
+    t.column "iso3166_country_code", :string
+    t.column "city",                 :string
+    t.column "submitter_label",      :string
+    t.column "uri",                  :string
+    t.column "retrieved_at",         :datetime
+    t.column "created_at",           :datetime
+    t.column "submitter_uri",        :string
+    t.column "country",              :string
+    t.column "updated_at",           :datetime
+    t.column "service_id",           :integer
+    t.column "flag_url",             :string
+    t.column "created",              :datetime
+    t.column "endpoint",             :string
+  end
+
+  create_table "service_providers", :force => true do |t|
+    t.column "name",         :string
+    t.column "uri",          :string
+    t.column "retrieved_at", :datetime
+    t.column "created_at",   :datetime
+    t.column "updated_at",   :datetime
+    t.column "description",  :text
+    t.column "created",      :datetime
+  end
+
+  create_table "service_tags", :force => true do |t|
+    t.column "label",        :string
+    t.column "uri",          :string
+    t.column "retrieved_at", :datetime
+    t.column "created_at",   :datetime
+    t.column "updated_at",   :datetime
+    t.column "service_id",   :integer
+  end
+
+  create_table "service_types", :force => true do |t|
+    t.column "label",        :string
+    t.column "retrieved_at", :datetime
+    t.column "created_at",   :datetime
+    t.column "updated_at",   :datetime
+    t.column "service_id",   :integer
+  end
+
+  create_table "services", :force => true do |t|
+    t.column "iso3166_country_code",     :string
+    t.column "city",                     :string
+    t.column "name",                     :string
+    t.column "contributor_id",           :integer
+    t.column "submitter_label",          :string
+    t.column "uri",                      :string
+    t.column "retrieved_at",             :datetime
+    t.column "created_at",               :datetime
+    t.column "monitor_symbol_url",       :string
+    t.column "country",                  :string
+    t.column "submitter_uri",            :string
+    t.column "updated_at",               :datetime
+    t.column "monitor_message",          :text
+    t.column "monitor_label",            :string
+    t.column "monitor_last_checked",     :datetime
+    t.column "monitor_small_symbol_url", :string
+    t.column "description",              :text
+    t.column "flag_url",                 :string
+    t.column "wsdl",                     :string
+    t.column "provider_label",           :string
+    t.column "contributor_type",         :string
+    t.column "documentation_uri",        :string
+    t.column "endpoint",                 :string
+    t.column "provider_uri",             :string
+    t.column "created",                  :datetime
+  end
+
+  create_table "sessions", :force => true do |t|
+    t.column "session_id", :string
+    t.column "data",       :text
+    t.column "updated_at", :datetime
+  end
+
+  add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
+  add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
+
+  create_table "taggings", :force => true do |t|
+    t.column "tag_id",        :integer
+    t.column "taggable_id",   :integer
+    t.column "taggable_type", :string
+    t.column "user_id",       :integer
+    t.column "created_at",    :datetime
+  end
+
+  add_index "taggings", ["tag_id", "taggable_type"], :name => "index_taggings_on_tag_id_and_taggable_type"
+  add_index "taggings", ["user_id", "tag_id", "taggable_type"], :name => "index_taggings_on_user_id_and_tag_id_and_taggable_type"
+  add_index "taggings", ["taggable_id", "taggable_type"], :name => "index_taggings_on_taggable_id_and_taggable_type"
+  add_index "taggings", ["user_id", "taggable_id", "taggable_type"], :name => "index_taggings_on_user_id_and_taggable_id_and_taggable_type"
+
+  create_table "tags", :force => true do |t|
+    t.column "name",             :string
+    t.column "taggings_count",   :integer,  :default => 0, :null => false
+    t.column "vocabulary_id",    :integer
+    t.column "description",      :text
+    t.column "description_html", :text
+    t.column "created_at",       :datetime
+    t.column "updated_at",       :datetime
+  end
+
+  add_index "tags", ["name"], :name => "index_tags_on_name"
+  add_index "tags", ["taggings_count"], :name => "index_tags_on_taggings_count"
+
+  create_table "taverna_enactors", :force => true do |t|
+    t.column "title",            :string
+    t.column "description",      :text
+    t.column "contributor_id",   :integer
+    t.column "contributor_type", :string
+    t.column "url",              :string
+    t.column "username",         :string
+    t.column "crypted_password", :string
+    t.column "created_at",       :datetime
+    t.column "updated_at",       :datetime
+  end
+
+  create_table "topic_feedbacks", :force => true do |t|
+    t.column "submit_dt", :datetime
+    t.column "user_id",   :integer
+    t.column "score",     :integer
+    t.column "topic_id",  :integer
+  end
+
+  create_table "topic_runs", :force => true do |t|
+    t.column "runtime",     :datetime
+    t.column "description", :string
+  end
+
+  create_table "topic_tag_map", :force => true do |t|
+    t.column "display_flag", :boolean
+    t.column "tag_id",       :integer
+    t.column "topic_id",     :integer
+    t.column "probability",  :float
+  end
+
+  create_table "topic_workflow_map", :force => true do |t|
+    t.column "display_flag", :boolean
+    t.column "workflow_id",  :integer
+    t.column "topic_id",     :integer
+    t.column "probability",  :float
+  end
+
+  create_table "topics", :force => true do |t|
+    t.column "name",        :string
+    t.column "orig_run_id", :integer
+    t.column "run_id",      :integer
+  end
+
+  create_table "user_reports", :force => true do |t|
+    t.column "report",       :text
+    t.column "created_at",   :datetime
+    t.column "subject_id",   :integer
+    t.column "subject_type", :string
+    t.column "user_id",      :integer
+    t.column "content",      :text
+  end
+
+  create_table "users", :force => true do |t|
+    t.column "openid_url",                :string
+    t.column "name",                      :string
+    t.column "created_at",                :datetime
+    t.column "updated_at",                :datetime
+    t.column "last_seen_at",              :datetime
+    t.column "username",                  :string
+    t.column "crypted_password",          :string,   :limit => 40
+    t.column "salt",                      :string,   :limit => 40
+    t.column "remember_token",            :string
+    t.column "remember_token_expires_at", :datetime
+    t.column "downloads_count",           :integer,                :default => 0
+    t.column "viewings_count",            :integer,                :default => 0
+    t.column "email",                     :string
+    t.column "unconfirmed_email",         :string
+    t.column "email_confirmed_at",        :datetime
+    t.column "activated_at",              :datetime
+    t.column "receive_notifications",     :boolean,                :default => true
+    t.column "reset_password_code",       :string
+    t.column "reset_password_code_until", :datetime
+  end
+
+  create_table "viewings", :force => true do |t|
+    t.column "contribution_id",    :integer
+    t.column "user_id",            :integer
+    t.column "created_at",         :datetime
+    t.column "user_agent",         :string
+    t.column "accessed_from_site", :boolean,  :default => false
+  end
+
+  add_index "viewings", ["contribution_id"], :name => "index_viewings_on_contribution_id"
+
+  create_table "vocabularies", :force => true do |t|
+    t.column "created_at",       :datetime
+    t.column "description_html", :text
+    t.column "uri",              :string
+    t.column "prefix",           :string
+    t.column "title",            :string
+    t.column "updated_at",       :datetime
+    t.column "user_id",          :integer
+    t.column "description",      :text
+  end
+
+  create_table "workflow_processors", :force => true do |t|
+    t.column "name",           :string
+    t.column "wsdl_operation", :string
+    t.column "workflow_id",    :integer
+    t.column "wsdl",           :string
+  end
+
+  create_table "workflow_versions", :force => true do |t|
+    t.column "contributor_id",    :integer
+    t.column "revision_comments", :text
+    t.column "created_at",        :datetime
+    t.column "body_html",         :text
+    t.column "body",              :text
+    t.column "title",             :string
+    t.column "content_blob_id",   :integer
+    t.column "license",           :string
+    t.column "updated_at",        :datetime
+    t.column "last_edited_by",    :string
+    t.column "svg",               :string
+    t.column "unique_name",       :string
+    t.column "content_type_id",   :integer
+    t.column "version",           :integer
+    t.column "workflow_id",       :integer
+    t.column "contributor_type",  :string
+    t.column "preview_id",        :integer
+    t.column "image",             :string
+    t.column "file_ext",          :string
+  end
+
+  add_index "workflow_versions", ["workflow_id"], :name => "index_workflow_versions_on_workflow_id"
+
+  create_table "workflows", :force => true do |t|
+    t.column "contributor_id",   :integer
+    t.column "created_at",       :datetime
+    t.column "body_html",        :text
+    t.column "body",             :text
+    t.column "title",            :string
+    t.column "content_blob_id",  :integer
+    t.column "updated_at",       :datetime
+    t.column "last_edited_by",   :string
+    t.column "svg",              :string
+    t.column "license_id",       :integer
+    t.column "unique_name",      :string
+    t.column "content_type_id",  :integer
+    t.column "current_version",  :integer
+    t.column "contributor_type", :string
+    t.column "preview_id",       :integer
+    t.column "image",            :string
+    t.column "file_ext",         :string
+  end
+
+end

Modified: trunk/public/stylesheets/styles.css (2782 => 2783)


--- trunk/public/stylesheets/styles.css	2011-11-02 11:49:00 UTC (rev 2782)
+++ trunk/public/stylesheets/styles.css	2011-11-02 14:18:04 UTC (rev 2783)
@@ -781,6 +781,7 @@
 	padding: 0.5em;
 	margin-bottom: 1.5em;
 	background-color: #F5F5F5;
+  margin: 0 auto 1.5em auto;
 }
 
 #errorExplanation h2 {

Modified: trunk/test/fixtures/networks.yml (2782 => 2783)


--- trunk/test/fixtures/networks.yml	2011-11-02 11:49:00 UTC (rev 2782)
+++ trunk/test/fixtures/networks.yml	2011-11-02 14:18:04 UTC (rev 2783)
@@ -22,3 +22,10 @@
   unique_name: network
   created_at: 2007-12-05 15:45:59
   updated_at: 2007-12-05 15:45:59
+
+exclusive_network:
+  title: An Invite Only Network
+  unique_name: invite_only
+  created_at: 2007-12-05 15:45:59
+  updated_at: 2007-12-05 15:45:59
+  new_member_policy: :invitation_only

Modified: trunk/test/functional/memberships_controller_test.rb (2782 => 2783)


--- trunk/test/functional/memberships_controller_test.rb	2011-11-02 11:49:00 UTC (rev 2782)
+++ trunk/test/functional/memberships_controller_test.rb	2011-11-02 14:18:04 UTC (rev 2783)
@@ -74,4 +74,10 @@
     assert_redirected_to group_path(networks(:another_network).id )
     assert_equal old_count-1, Membership.count
   end
+
+  def test_cannot_join_invitation_only_group
+    assert_no_difference 'Membership.count' do
+      post :create, :user_id => users(:john).id, :network_id => networks(:exclusive_network).id
+    end
+  end
 end

Modified: trunk/test/functional/networks_controller_test.rb (2782 => 2783)


--- trunk/test/functional/networks_controller_test.rb	2011-11-02 11:49:00 UTC (rev 2782)
+++ trunk/test/functional/networks_controller_test.rb	2011-11-02 14:18:04 UTC (rev 2783)
@@ -35,7 +35,7 @@
     old_count = Network.count
 
     login_as(:john)
-    post :create, :network => { :user_id => '990', :title => 'test network', :unique_name => 'test_network', :auto_accept => '0', :description => "..." }
+    post :create, :network => { :user_id => '990', :title => 'test network', :unique_name => 'test_network', :new_member_policy => 'open', :description => "..." }
 
     assert_equal old_count+1, Network.count    
     assert_redirected_to group_path(assigns(:network))
@@ -56,7 +56,7 @@
   def test_should_update_network
     login_as(:john)
     put :update, :id => 1, 
-                 :network => { :user_id => '990', :title => 'test network', :unique_name => 'update_network', :auto_accept => '0', :description => ".?."}
+                 :network => { :user_id => '990', :title => 'test network', :unique_name => 'update_network', :new_member_policy => 'open', :description => ".?."}
 
     assert_redirected_to group_path(assigns(:network))
   end

reply via email to

[Prev in Thread] Current Thread [Next in Thread]