archive now as all other modules
This commit is contained in:
		
							parent
							
								
									1526e3eccc
								
							
						
					
					
						commit
						9e40b65405
					
				|  | @ -1,16 +1,9 @@ | ||||||
| class ArchivesController < ApplicationController | class ArchivesController < ApplicationController | ||||||
| 	def index		 | 	def index		 | ||||||
| 		files_by_cateogry = ArchiveFile.filter_by_categories.filter_by_tags.group_by(&:category) | 		files_by_cateogry = ArchiveFile.filter_by_categories.filter_by_tags.group_by(&:category) | ||||||
| 		cats = files_by_cateogry.keys.collect do |cat| | 		categories = files_by_cateogry.keys | ||||||
| 			 | 		cats = categories.collect do |category| | ||||||
| 			files_by_category_tag = files_by_cateogry[cat].group_by(&:tags) | 			archives = files_by_cateogry[category].collect do |archive| | ||||||
| 			url_to_edit = OrbitHelper.user_has_cateogry?(cat) ? "/admin/archive_files?filters[category][]=#{cat.id.to_s}" : "" |  | ||||||
| 			ts = [] |  | ||||||
| 			files_by_category_tag.keys.each do |t| |  | ||||||
| 
 |  | ||||||
| 				archives = [] |  | ||||||
| 				files_by_category_tag[t].each_with_index do |archive,index| |  | ||||||
| 				 |  | ||||||
| 				statuses = archive.statuses_with_classname.collect do |status| | 				statuses = archive.statuses_with_classname.collect do |status| | ||||||
| 			        { | 			        { | ||||||
| 			          "status" => status["name"] || "", | 			          "status" => status["name"] || "", | ||||||
|  | @ -22,7 +15,6 @@ class ArchivesController < ApplicationController | ||||||
| 					if file.choose_lang.include?(I18n.locale.to_s) | 					if file.choose_lang.include?(I18n.locale.to_s) | ||||||
| 						title = (file.file_title.blank? ?  File.basename(file.file.path) : file.file_title) rescue "" | 						title = (file.file_title.blank? ?  File.basename(file.file.path) : file.file_title) rescue "" | ||||||
| 						extension = file.file.file.extension.downcase rescue "" | 						extension = file.file.file.extension.downcase rescue "" | ||||||
| 							# url = file.file.url rescue "" |  | ||||||
| 						files <<  { | 						files <<  { | ||||||
| 							"file-name" => title, | 							"file-name" => title, | ||||||
| 							"file-type" =>  extension, | 							"file-type" =>  extension, | ||||||
|  | @ -30,48 +22,16 @@ class ArchivesController < ApplicationController | ||||||
| 						} | 						} | ||||||
| 					end | 					end | ||||||
| 				end | 				end | ||||||
| 					a = { | 				{ | ||||||
| 						"archive-title" => archive.title || "", | 					"archive-title" => archive.title, | ||||||
| 					"statuses" => statuses, | 					"statuses" => statuses, | ||||||
| 					"files" => files | 					"files" => files | ||||||
| 				} | 				} | ||||||
| 					if t.count > 1 |  | ||||||
| 						t.each do |inner_tag| |  | ||||||
| 							index = ts.index{|tot| tot["tag-name"] == inner_tag.name} |  | ||||||
| 							if index.nil? |  | ||||||
| 								ts << { |  | ||||||
| 									"tag-name" => (inner_tag.name rescue ""), |  | ||||||
| 									"archives" => [a] |  | ||||||
| 								} |  | ||||||
| 							else |  | ||||||
| 								ts[index]["archives"] << a |  | ||||||
| 			end | 			end | ||||||
| 						end | 			{ | ||||||
| 					else | 				"category-title" => category.title, | ||||||
| 						archives << a |  | ||||||
| 					end |  | ||||||
| 				end				 |  | ||||||
| 				ts << { |  | ||||||
| 					"tag-name" => (t[0].name rescue ""), |  | ||||||
| 				"archives" => archives | 				"archives" => archives | ||||||
| 
 |  | ||||||
| 				} if !archives.blank? |  | ||||||
| 			end |  | ||||||
| 			if(files_by_category_tag.empty?) |  | ||||||
| 				{ |  | ||||||
| 					"category-title" => "", |  | ||||||
| 					"tags" => ts, |  | ||||||
| 					"url_to_edit" => url_to_edit |  | ||||||
| 					 |  | ||||||
| 			} | 			} | ||||||
| 			else |  | ||||||
| 				{ |  | ||||||
| 					"category-title" => cat.title || "", |  | ||||||
| 					"tags" => ts, |  | ||||||
| 					"url_to_edit" => url_to_edit |  | ||||||
| 					 |  | ||||||
| 				} |  | ||||||
| 			end |  | ||||||
| 		end | 		end | ||||||
| 		{ | 		{ | ||||||
| 			"categories" => cats | 			"categories" => cats | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue