Revision 1078:b9e34a051f82 app/controllers
| app/controllers/activities_controller.rb | ||
|---|---|---|
| 40 | 40 |
|
| 41 | 41 |
events = @activity.events(@date_from, @date_to) |
| 42 | 42 |
|
| 43 |
if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, User.current, current_language]) |
|
| 43 |
@institution_name = params[:institution] |
|
| 44 |
if !@institution_name.blank? |
|
| 45 |
events = events.select do |e| |
|
| 46 |
e.respond_to?(:event_author) and e.event_author and |
|
| 47 |
e.event_author.respond_to?(:ssamr_user_detail) and |
|
| 48 |
!e.event_author.ssamr_user_detail.nil? and |
|
| 49 |
e.event_author.ssamr_user_detail.institution_name == @institution_name |
|
| 50 |
end |
|
| 51 |
if events.empty? |
|
| 52 |
# We don't want to dump into the output any arbitrary string |
|
| 53 |
# from the URL that has no matching events |
|
| 54 |
@institution_name = "" |
|
| 55 |
end |
|
| 56 |
end |
|
| 57 |
|
|
| 58 |
if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, @institution_name, events.first, User.current, current_language]) |
|
| 44 | 59 |
respond_to do |format| |
| 45 | 60 |
format.html {
|
| 46 | 61 |
@events_by_day = events.group_by(&:event_date) |
| app/controllers/attachments_controller.rb | ||
|---|---|---|
| 17 | 17 |
|
| 18 | 18 |
class AttachmentsController < ApplicationController |
| 19 | 19 |
|
| 20 |
include AttachmentsHelper |
|
| 21 |
helper :attachments |
|
| 22 |
|
|
| 20 | 23 |
before_filter :find_project |
| 21 | 24 |
before_filter :file_readable, :read_authorize, :except => :destroy |
| 22 | 25 |
before_filter :delete_authorize, :only => :destroy |
| ... | ... | |
| 49 | 52 |
end |
| 50 | 53 |
|
| 51 | 54 |
def download |
| 52 |
if @attachment.container.is_a?(Version) || @attachment.container.is_a?(Project) |
|
| 55 |
# cc: formerly this happened only if "@attachment.container.is_a?(Version)" |
|
| 56 |
# or Project. Not good for us, we want to tally all downloads [by humans] |
|
| 57 |
if not user_is_search_bot? |
|
| 53 | 58 |
@attachment.increment_download |
| 54 | 59 |
end |
| 55 | 60 |
|
| app/controllers/projects_controller.rb | ||
|---|---|---|
| 20 | 20 |
menu_item :roadmap, :only => :roadmap |
| 21 | 21 |
menu_item :settings, :only => :settings |
| 22 | 22 |
|
| 23 |
before_filter :find_project, :except => [ :index, :list, :new, :create, :copy ] |
|
| 24 |
before_filter :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy] |
|
| 23 |
before_filter :find_project, :except => [ :index, :list, :explore, :new, :create, :copy ]
|
|
| 24 |
before_filter :authorize, :except => [ :index, :list, :explore, :new, :create, :copy, :archive, :unarchive, :destroy]
|
|
| 25 | 25 |
before_filter :authorize_global, :only => [:new, :create] |
| 26 | 26 |
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ] |
| 27 | 27 |
accept_rss_auth :index |
| ... | ... | |
| 43 | 43 |
helper :repositories |
| 44 | 44 |
include RepositoriesHelper |
| 45 | 45 |
include ProjectsHelper |
| 46 |
include ActivitiesHelper |
|
| 47 |
helper :activities |
|
| 46 | 48 |
|
| 47 | 49 |
# Lists visible projects. Paginator is for top-level projects only |
| 48 | 50 |
# (subprojects belong to them) |
| ... | ... | |
| 76 | 78 |
end |
| 77 | 79 |
end |
| 78 | 80 |
|
| 81 |
# A different view of projects using explore boxes |
|
| 82 |
def explore |
|
| 83 |
respond_to do |format| |
|
| 84 |
format.html {
|
|
| 85 |
@projects = Project.visible |
|
| 86 |
render :template => 'projects/explore.html.erb', :layout => !request.xhr? |
|
| 87 |
} |
|
| 88 |
end |
|
| 89 |
end |
|
| 90 |
|
|
| 79 | 91 |
def new |
| 80 | 92 |
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
|
| 81 | 93 |
@trackers = Tracker.all |
| ... | ... | |
| 99 | 111 |
end |
| 100 | 112 |
# end of code to be removed |
| 101 | 113 |
|
| 102 |
|
|
| 103 |
if validate_parent_id && @project.save |
|
| 114 |
if validate_is_public_key && validate_parent_id && @project.save |
|
| 104 | 115 |
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
|
| 105 | 116 |
# Add current user as a project member if he is not admin |
| 106 | 117 |
unless User.current.admin? |
| ... | ... | |
| 288 | 299 |
render_404 |
| 289 | 300 |
end |
| 290 | 301 |
|
| 302 |
def validate_is_public_key |
|
| 303 |
# Although is_public isn't mandatory in the project model (it gets |
|
| 304 |
# defaulted), it must be present in params -- it can be true or |
|
| 305 |
# false, but it must be there. This permits us to make forms in |
|
| 306 |
# which the user _has_ to select public or private (rather than |
|
| 307 |
# defaulting it) if we want to |
|
| 308 |
if params.nil? || params[:project].nil? || !params[:project].has_key?(:is_public) |
|
| 309 |
@project.errors.add :is_public, :public_or_private |
|
| 310 |
return false |
|
| 311 |
end |
|
| 312 |
true |
|
| 313 |
end |
|
| 314 |
|
|
| 291 | 315 |
# Validates parent_id param according to user's permissions |
| 292 | 316 |
# TODO: move it to Project model in a validation that depends on User.current |
| 293 | 317 |
def validate_parent_id |
| app/controllers/welcome_controller.rb | ||
|---|---|---|
| 25 | 25 |
@site_project = Project.find_by_identifier "soundsoftware-site" |
| 26 | 26 |
@site_news = [] |
| 27 | 27 |
@site_news = News.latest_for @site_project if @site_project |
| 28 |
@projects = Project.latest User.current |
|
| 29 | 28 |
|
| 30 | 29 |
# tests if user is logged in to generate the tips of the day list |
| 31 | 30 |
if User.current.logged? |
Also available in: Unified diff