Skip to content

Commit

Permalink
update nepa views; resolved error on issue #9
Browse files Browse the repository at this point in the history
  • Loading branch information
eisemann committed Feb 11, 2015
1 parent 7bc9d5e commit ab58354
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
12 changes: 8 additions & 4 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
class User < ActiveRecord::Base
# Virtual attribute for the unencrypted password
attr_accessor :password

has_many :memberships, :dependent => :destroy
has_many :groups, :through => :memberships

has_many :my_maps, :dependent => :destroy
has_many :maps, :through => :my_maps, :uniq => true
has_many :layers
Expand All @@ -26,7 +26,7 @@ class User < ActiveRecord::Base

has_many :permissions
has_many :roles, :through => :permissions

before_save :encrypt_password
before_create :make_activation_code

Expand Down Expand Up @@ -181,6 +181,10 @@ def has_role?(name)
self.roles.find_by_name(name) ? true : false
end

def nepa_admin?
has_role?("administrator") || has_role?("super user")
end

#outside of protected and private scope, so an admin can force activate a user
def force_activate!
@activated = true
Expand Down Expand Up @@ -215,7 +219,7 @@ def make_password_reset_code
self.password_reset_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )
end


private

def activate!
Expand Down
8 changes: 4 additions & 4 deletions app/views/nepa_documents/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@
link_to 'View Associated Map', map_path(nepa_document.map_id), :class => "btn btn-default", :role => "button"
else

if current_user.has_role?("administrator") || current_user.has_role?("super user")
if logged_in? && current_user.nepa_admin?
#link_to "Assign to Map", assign_nepa_document_path(nepa_document)
link_to "Assign to Project Map", {:controller => 'maps', :action =>'nepaproject', :nepa => "assign", :doc => nepa_document.id}, :class => "btn btn-default", :role => "button"
end

end
%>
</td>
<td><% if current_user.has_role?("administrator") || current_user.has_role?("super user") %><%= link_to 'Edit', edit_nepa_document_path(nepa_document), :class => "btn btn-default", :role => "button" %><% end %></td>
<td><% if current_user.has_role?("administrator") || current_user.has_role?("super user") %><%= link_to 'Destroy', nepa_document, :confirm => 'Are you sure?', :method => :delete, :class => "btn btn-default", :role => "button" %><% end %></td>
<td><% if logged_in? && current_user.nepa_admin? %><%= link_to 'Edit', edit_nepa_document_path(nepa_document), :class => "btn btn-default", :role => "button" %><% end %></td>
<td><% if logged_in? && current_user.nepa_admin? %><%= link_to 'Destroy', nepa_document, :confirm => 'Are you sure?', :method => :delete, :class => "btn btn-default", :role => "button" %><% end %></td>



Expand All @@ -73,7 +73,7 @@
<%= page_entries_info @nepa_documents %>.&nbsp;<%= select_tag :per_page, options_for_select([10,20,50,100], @per_page.to_i), :onchange => "if(this.value){reload_with_page(this.value)};" %> per page.
</div>

<% if current_user.has_role?("administrator") || current_user.has_role?("super user") %>
<% if logged_in? && current_user.nepa_admin? %>
<br/>
<p><%= link_to 'New NEPA Document', new_nepa_document_path, :class => "btn btn-default", :role => "button" %></p>
<% end %>
4 changes: 2 additions & 2 deletions app/views/nepa_documents/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
</table>
<%= link_to "View NEPA Milestones", nepa_document_nepa_milestones_path(@nepa_document), :class => "btn btn-default", :role => "button" %>
<% if current_user.has_role?("administrator") || current_user.has_role?("super user") %>
<% if logged_in? && current_user.nepa_admin? %>
<%= link_to 'Edit this NEPA Document', edit_nepa_document_path(@nepa_document), :class => "btn btn-default", :role => "button" %>
<% end %>
<%=
if @nepa_document.map_id.nil?
if current_user.has_role?("administrator") || current_user.has_role?("super user")
if logged_in? && current_user.nepa_admin?
link_to "Assign to Map", assign_nepa_document_path(@nepa_document), :class => "btn btn-default", :role => "button"
end
else
Expand Down
9 changes: 5 additions & 4 deletions app/views/nepa_milestones/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@
<tr>

<td>
<% #= nepa_milestone.milestone_type %>
<%= nepa_milestone.nepa_lookup_milestone.milestone %>
<!-- <%= nepa_milestone.milestone_type %> -->
(<%= nepa_milestone.milestone_type %>)&nbsp;
<%= nepa_milestone.nepa_lookup_milestone ? nepa_milestone.nepa_lookup_milestone.milestone : "[DNE]" %>
</td>
<td><%= nepa_milestone.actual_start_date.try(:strftime, '%m/%d/%Y') %></td>
<td><%= nepa_milestone.actual_completion_date.try(:strftime, '%m/%d/%Y') %></td>

<td>
<%= link_to 'View', nepa_document_nepa_milestone_path(@nepa_document, nepa_milestone), :class => "btn btn-default", :role => "button" %>
<% if current_user.has_role?("administrator") || current_user.has_role?("super user") %>
<% if logged_in? && current_user.nepa_admin? %>
<%= link_to 'Edit', edit_nepa_document_nepa_milestone_path(@nepa_document, nepa_milestone), :class => "btn btn-default", :role => "button" %>
<%= link_to 'Delete', nepa_document_nepa_milestone_path(nepa_milestone.nepa_document_id, nepa_milestone.id), :method => :delete, :class => "btn btn-default", :role => "button" %>
<% end %>
Expand All @@ -34,7 +35,7 @@
</tbody>
</table>

<% if current_user.has_role?("administrator") || current_user.has_role?("super user") %>
<% if logged_in? && current_user.nepa_admin? %>
<%= link_to 'Add Milestone', new_nepa_document_nepa_milestone_path, :class => "btn btn-default", :role => "button" %>
<% end %>

Expand Down
2 changes: 1 addition & 1 deletion app/views/nepa_milestones/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</table>
<% if current_user.has_role?("administrator") || current_user.has_role?("super user") %>
<% if logged_in? && current_user.nepa_admin? %>
<%= link_to 'Edit', edit_nepa_document_nepa_milestone_path(@nepa_document, @nepa_milestone), :class => "btn btn-default", :role => "button" %>
<% end %>
<%= link_to 'Back to Viewing all Milestones', nepa_document_nepa_milestones_path, :class => "btn btn-default", :role => "button" %>

0 comments on commit ab58354

Please sign in to comment.