Paginas wiki, arquivos e disciplinas ocultas
This commit is contained in:
@@ -27,6 +27,10 @@ class Attachment < ActiveRecord::Base
|
||||
# Validacao
|
||||
generate_validations
|
||||
|
||||
def self.find_front_page
|
||||
Attachment.find(:all, :conditions => [ "front_page = ?", true ])
|
||||
end
|
||||
|
||||
# Atributo virtual file
|
||||
def file=(new_file)
|
||||
@tmp_file = new_file
|
||||
|
||||
@@ -51,6 +51,10 @@ class Course < ActiveRecord::Base
|
||||
def related_courses
|
||||
Course.find(:all, :conditions => [ 'short_name = ?', self.short_name], :limit => 4, :order => 'period desc')
|
||||
end
|
||||
|
||||
def recent_news
|
||||
self.news.find(:all, :conditions => [ 'timestamp > ?', 7.days.ago ])
|
||||
end
|
||||
|
||||
def after_create
|
||||
App.inital_wiki_pages.each do |page_title|
|
||||
|
||||
@@ -25,7 +25,7 @@ class NewsDeleteLogEntry < NewsLogEntry
|
||||
news.deleted?
|
||||
end
|
||||
def undo!(current_user)
|
||||
news.restore!
|
||||
news.recover!
|
||||
NewsRestoreLogEntry.create!(:target_id => news.id, :user_id => current_user.id, :course => news.course, :version => news.version)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,6 +25,7 @@ class WikiPage < ActiveRecord::Base
|
||||
acts_as_list :scope => 'course_id = #{course_id}'
|
||||
acts_as_versioned :if_changed => [ :content, :description, :title ]
|
||||
acts_as_paranoid_versioned
|
||||
self.non_versioned_columns << 'front_page'
|
||||
self.non_versioned_columns << 'position'
|
||||
self.non_versioned_columns << 'deleted_at'
|
||||
self.non_versioned_columns << 'canonical_title'
|
||||
@@ -43,6 +44,14 @@ class WikiPage < ActiveRecord::Base
|
||||
self.canonical_title = self.title.pretty_url
|
||||
end
|
||||
|
||||
def before_save
|
||||
if !self.front_page
|
||||
self.remove_from_list
|
||||
elsif self.position.nil?
|
||||
self.insert_at(1)
|
||||
end
|
||||
end
|
||||
|
||||
def validate
|
||||
begin
|
||||
self.content.format_wiki
|
||||
@@ -55,6 +64,10 @@ class WikiPage < ActiveRecord::Base
|
||||
self.canonical_title
|
||||
end
|
||||
|
||||
def self.find_front_page
|
||||
WikiPage.find(:all, :conditions => [ "front_page = ?", true ])
|
||||
end
|
||||
|
||||
def WikiPage.diff(from, to)
|
||||
# Cria um arquivo com o conteudo da versao antiga
|
||||
original_content_file = Tempfile.new("old")
|
||||
|
||||
Reference in New Issue
Block a user