Mercurial > hg > soundsoftware-site
comparison app/helpers/projects_helper.rb @ 84:432bb11e0390 cannam
Merge from branch "luisf"
author | Chris Cannam |
---|---|
date | Thu, 16 Dec 2010 10:03:20 +0000 |
parents | dc22c3eb3c81 |
children | 1412841d48a3 |
comparison
equal
deleted
inserted
replaced
76:8a49eabbb30a | 84:432bb11e0390 |
---|---|
81 @project = original_project | 81 @project = original_project |
82 end | 82 end |
83 s | 83 s |
84 end | 84 end |
85 | 85 |
86 | |
87 # Renders a tree of projects where the current user belongs | |
88 # as a nested set of unordered lists | |
89 # The given collection may be a subset of the whole project tree | |
90 # (eg. some intermediate nodes are private and can not be seen) | |
91 def render_my_project_hierarchy(projects) | |
92 s = '' | |
93 | |
94 a = '' | |
95 | |
96 # Flag to tell if user has any projects | |
97 t = FALSE | |
98 | |
99 if projects.any? | |
100 ancestors = [] | |
101 original_project = @project | |
102 projects.each do |project| | |
103 # set the project environment to please macros. | |
104 | |
105 @project = project | |
106 | |
107 if User.current.member_of?(project): | |
108 | |
109 t = TRUE | |
110 | |
111 if (ancestors.empty? || project.is_descendant_of?(ancestors.last)) | |
112 s << "<ul class='projects #{ ancestors.empty? ? 'root' : nil}'>\n" | |
113 else | |
114 ancestors.pop | |
115 s << "</li>" | |
116 while (ancestors.any? && !project.is_descendant_of?(ancestors.last)) | |
117 ancestors.pop | |
118 s << "</ul></li>\n" | |
119 end | |
120 end | |
121 | |
122 classes = (ancestors.empty? ? 'root' : 'child') | |
123 s << "<li class='#{classes}'><div class='#{classes}'>" + | |
124 link_to_project(project, {}, :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}") | |
125 s << "<div class='wiki description'>#{textilizable(project.short_description, :project => project)}</div>" unless project.description.blank? | |
126 s << "</div>\n" | |
127 ancestors << project | |
128 end | |
129 end | |
130 s << ("</li></ul>\n" * ancestors.size) | |
131 @project = original_project | |
132 end | |
133 | |
134 if t == TRUE | |
135 a << "<h2>" | |
136 a << l("label_my_project_plural") | |
137 a << "</h2>" | |
138 a << s | |
139 else | |
140 a = s | |
141 end | |
142 | |
143 a | |
144 end | |
145 | |
146 # Renders a tree of projects where the current DOES NOT belong | |
147 # as a nested set of unordered lists | |
148 # The given collection may be a subset of the whole project tree | |
149 # (eg. some intermediate nodes are private and can not be seen) | |
150 def render_other_project_hierarchy(projects) | |
151 s = '' | |
152 | |
153 if projects.any? | |
154 ancestors = [] | |
155 original_project = @project | |
156 projects.each do |project| | |
157 # set the project environment to please macros. | |
158 | |
159 @project = project | |
160 | |
161 if not User.current.member_of?(project): | |
162 | |
163 if (ancestors.empty? || project.is_descendant_of?(ancestors.last)) | |
164 s << "<ul class='projects #{ ancestors.empty? ? 'root' : nil}'>\n" | |
165 else | |
166 ancestors.pop | |
167 s << "</li>" | |
168 while (ancestors.any? && !project.is_descendant_of?(ancestors.last)) | |
169 ancestors.pop | |
170 s << "</ul></li>\n" | |
171 end | |
172 end | |
173 | |
174 classes = (ancestors.empty? ? 'root' : 'child') | |
175 s << "<li class='#{classes}'><div class='#{classes}'>" + | |
176 link_to_project(project, {}, :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}") | |
177 s << "<div class='wiki description'>#{textilizable(project.short_description, :project => project)}</div>" unless project.description.blank? | |
178 s << "</div>\n" | |
179 ancestors << project | |
180 end | |
181 end | |
182 | |
183 s << ("</li></ul>\n" * ancestors.size) | |
184 @project = original_project | |
185 end | |
186 | |
187 | |
188 s | |
189 end | |
190 | |
191 | |
192 | |
86 # Returns a set of options for a select field, grouped by project. | 193 # Returns a set of options for a select field, grouped by project. |
87 def version_options_for_select(versions, selected=nil) | 194 def version_options_for_select(versions, selected=nil) |
88 grouped = Hash.new {|h,k| h[k] = []} | 195 grouped = Hash.new {|h,k| h[k] = []} |
89 versions.each do |version| | 196 versions.each do |version| |
90 grouped[version.project.name] << [version.name, version.id] | 197 grouped[version.project.name] << [version.name, version.id] |