Paginas wiki, arquivos e disciplinas ocultas
This commit is contained in:
@@ -35,6 +35,7 @@ class AttachmentsController < ApplicationController
|
||||
def create
|
||||
@attachment.course_id = @course.id
|
||||
@attachment.path = params[:attachment][:path]
|
||||
@attachment.front_page = params[:attachment][:front_page]
|
||||
@attachment.description = params[:attachment][:description]
|
||||
@attachment.file_name = "blank"
|
||||
unless params[:attachment][:file].nil?
|
||||
@@ -58,6 +59,7 @@ class AttachmentsController < ApplicationController
|
||||
|
||||
def update
|
||||
@attachment.path = params[:attachment][:path]
|
||||
@attachment.front_page = params[:attachment][:front_page]
|
||||
@attachment.description = params[:attachment][:description]
|
||||
unless params[:attachment][:file].nil?
|
||||
@attachment.file = params[:attachment][:file]
|
||||
@@ -93,10 +95,11 @@ class AttachmentsController < ApplicationController
|
||||
end
|
||||
|
||||
def download
|
||||
|
||||
send_file("#{RAILS_ROOT}/public/upload/#{@course.id}/#{@attachment.id}",
|
||||
:filename => @attachment.file_name,
|
||||
:type => @attachment.content_type,
|
||||
:disposition => 'attachment',
|
||||
:disposition => 'inline',
|
||||
:streaming => 'true')
|
||||
end
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@ class CoursesController < ApplicationController
|
||||
@period = params[:period] || App.current_period
|
||||
|
||||
if logged_in? and !@current_user.courses.empty?
|
||||
@courses = Course.find(:all, :order => 'grade asc, full_name asc', :conditions => ['period = ? and id not in (?)', @period, @current_user.courses])
|
||||
@courses = Course.find(:all, :order => 'grade asc, full_name asc', :conditions => ['period = ? and hidden = ? and id not in (?)', @period, false, @current_user.courses])
|
||||
else
|
||||
@courses = Course.find(:all, :order => 'grade asc, full_name asc', :conditions => ['period = ?', @period])
|
||||
@courses = Course.find(:all, :order => 'grade asc, full_name asc', :conditions => ['period = ? and hidden = ?', @period, false])
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
@@ -22,7 +22,9 @@ class LogController < ApplicationController
|
||||
if @course
|
||||
@log_entries = @course.log_entries.paginate(:page => params[:page], :per_page => 30, :order => "created_at desc")
|
||||
else
|
||||
@log_entries = LogEntry.paginate(:page => params[:page], :per_page => 30, :order => "created_at desc")
|
||||
@log_entries = LogEntry.paginate(:page => params[:page], :per_page => 30,
|
||||
:conditions => [ "course_id not in (select id from courses where hidden = ?)", true],
|
||||
:order => "created_at desc")
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
@@ -29,7 +29,7 @@ class WikiController < ApplicationController
|
||||
|
||||
def index
|
||||
respond_to do |format|
|
||||
format.html { redirect_to course_url(@course) }
|
||||
format.html
|
||||
format.xml { render :xml => @wiki_pages }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -13,4 +13,6 @@
|
||||
|
||||
%dt
|
||||
%label{:for => "attachment_description"} Descrição
|
||||
%dd= preserve(text_area 'attachment', 'description')
|
||||
%dd= preserve(text_area 'attachment', 'description', {:rows => 10})
|
||||
|
||||
%dt= check_box('attachment', 'front_page') + " Exibir arquivo na página inicial do curso"
|
||||
|
||||
15
app/views/attachments/index.html.haml
Normal file
15
app/views/attachments/index.html.haml
Normal file
@@ -0,0 +1,15 @@
|
||||
.cmd
|
||||
= action_icon 'add', 'Adicionar', new_course_attachment_url(@course)
|
||||
|
||||
%h4.title= h(@course.full_name)
|
||||
%h1.title Repositório de Arquivos
|
||||
|
||||
.box.repositorio
|
||||
- if !@course.attachments.empty?
|
||||
%ul
|
||||
= nested_attachments_to_html(attachments_to_nested_hash(@course.attachments))
|
||||
|
||||
- else
|
||||
.box
|
||||
%ul
|
||||
%li.no_itens Nenhum arquivo
|
||||
@@ -3,7 +3,7 @@
|
||||
= action_icon 'trash', 'Excluir', course_attachment_url, :confirm => 'Tem certeza que deseja excluir o arquivo?', :method => :delete
|
||||
|
||||
%h4.title= h(@attachment.course.full_name)
|
||||
%h1.title Repositório
|
||||
%h1.title Repositório de Arquivos
|
||||
|
||||
%p
|
||||
%dl
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
%label{:for => "course_period"} Data
|
||||
%dd= text_field 'course', 'period'
|
||||
|
||||
%dt
|
||||
%label{:for => "course_hidden"} Ocultar
|
||||
%dd= check_box 'course', 'hidden'
|
||||
|
||||
%dt
|
||||
%label{:for => "course_description"} Descrição
|
||||
%dd= preserve(text_area('course', 'description', :cols => 60, :rows => 10))
|
||||
|
||||
@@ -10,13 +10,32 @@
|
||||
|
||||
%p= @course.description.format_wiki
|
||||
|
||||
-#.box
|
||||
-# .cmd
|
||||
-# = action_icon 'add', 'Adicionar notícia', new_course_news_instance_url(@course)
|
||||
-#
|
||||
-# %h3 Notícias Recentes
|
||||
-# %ul.news
|
||||
-# - @course.recent_news.each do |news|
|
||||
-# %li{highlight(news.id)}
|
||||
-# .cmd{:style => 'margin-top: -9px;'}
|
||||
-# = action_icon 'edit', 'Editar', edit_course_news_instance_url(@course, news, :version => news.version)
|
||||
-# = action_icon 'trash', 'Excluir', course_news_instance_url(@course, news), :confirm => 'Tem certeza que deseja excluir?', :method => :delete
|
||||
-# = link_to h(news.title), course_news_instance_url(@course, news)
|
||||
-# = formatted(news.body)
|
||||
-# = "Enviada por %s há %s." % [link_to(news.user.display_name, user_url(news.user)), distance_of_time_in_words(Time.now, news.timestamp)]
|
||||
-# - if @course.news.empty?
|
||||
-# %li.no_itens Nenhuma notícia recente
|
||||
-# - else
|
||||
-# %li.see_all= link_to "Ver todas as noticias", course_news_url(@course)
|
||||
|
||||
.box
|
||||
.cmd
|
||||
= action_icon 'add', 'Adicionar página wiki', new_course_wiki_instance_url(@course)
|
||||
|
||||
%h3 Páginas Wiki
|
||||
%ul.wiki
|
||||
- @course.wiki_pages.each do |wiki|
|
||||
- @course.wiki_pages.find_front_page.each do |wiki|
|
||||
%li{highlight(wiki.id)}
|
||||
.cmd{:style => 'margin-bottom: -27px; margin-top: -9px;'}
|
||||
=action_icon 'arrow2_n', 'Mover para cima', move_up_course_wiki_instance_url(@course, wiki) unless wiki.first?
|
||||
@@ -26,14 +45,18 @@
|
||||
=link_to h(wiki.title), course_wiki_instance_url(@course, wiki)
|
||||
- if @course.wiki_pages.empty?
|
||||
%li.no_itens Nenhuma página wiki
|
||||
- else
|
||||
%li.show_all= link_to "Ver todas as páginas wiki", course_wiki_url(@course)
|
||||
|
||||
.box
|
||||
.cmd= action_icon 'add', 'Adicionar anexo', new_course_attachment_url(@course)
|
||||
|
||||
%h3 Repositório de Arquivos
|
||||
.repositorio
|
||||
= nested_attachments_to_html(attachments_to_nested_hash(@course.attachments))
|
||||
= nested_attachments_to_html(attachments_to_nested_hash(@course.attachments.find_front_page))
|
||||
- if @course.attachments.empty?
|
||||
%ul.wiki
|
||||
%li.no_itens Nenhum arquivo
|
||||
- else
|
||||
%li.show_all= link_to "Ver todos os arquivos", course_attachments_url(@course)
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
= link_to(App.title, index_url) + "›"
|
||||
= link_to("Disciplinas", courses_url) + "›"
|
||||
= link_to(h(@course.full_name), course_url(@course)) + "›"
|
||||
= link_to("Arquivos", course_url(@course))
|
||||
= link_to("Arquivos", course_attachments_url(@course))
|
||||
- if @attachment.id
|
||||
= "›" + link_to(truncate(h(@attachment.file_name)), course_attachment_url)
|
||||
- @title = @title + " - #{truncate(h(@attachment.file_name))}"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
= link_to(App.title, index_url) + "›"
|
||||
= link_to("Disciplinas", courses_url) + "›"
|
||||
= link_to(h(@course.full_name), course_url(@course)) + "›"
|
||||
= link_to("Wiki", course_url(@course))
|
||||
= link_to("Wiki", course_wiki_url(@course))
|
||||
- if @wiki_page.title
|
||||
= "›" + link_to(h(@wiki_page.title), course_wiki_instance_url(@course, @wiki_page))
|
||||
- @title = @title + " - #{h(@wiki_page.title)}"
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
= javascript_include_tag 'news'
|
||||
|
||||
-# cache(course_news_path(@course.id)) do
|
||||
|
||||
.cmd
|
||||
= action_icon 'add', 'Adicionar', new_course_news_instance_url
|
||||
|
||||
@@ -22,7 +20,7 @@
|
||||
= n.timestamp.strftime("%d de %B")
|
||||
%td
|
||||
.title= link_to h(n.title), course_news_instance_url(@course, n)
|
||||
.description{:style => (n.id == params[:id].to_i ? '' : 'display: none')}
|
||||
.description
|
||||
.cmd
|
||||
= action_icon 'edit', 'Editar', edit_course_news_instance_url(@course, n, :version => n.version)
|
||||
= action_icon 'trash', 'Excluir', course_news_instance_url(@course, n), :confirm => 'Tem certeza que deseja excluir?', :method => :delete
|
||||
|
||||
@@ -231,7 +231,7 @@ body {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.menu li, .news li, #shoutbox li {
|
||||
.menu li, #shoutbox li {
|
||||
border-top: 1px solid #eee;
|
||||
margin-top: -1px;
|
||||
padding: 9px 10px;
|
||||
@@ -295,17 +295,10 @@ body {
|
||||
border-bottom: 0px solid #ccc;
|
||||
}
|
||||
|
||||
.widget_users li, .widget_news li, .widget_events li {
|
||||
.widget_users li {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.widget_news li, #shoutbox li {
|
||||
line-height: 18px;
|
||||
margin: 0px; margin-top: -1px;
|
||||
padding: 9px 0px;
|
||||
}
|
||||
|
||||
|
||||
#shoutbox textarea {
|
||||
font-family: sans-serif;
|
||||
font-size: 11px;
|
||||
@@ -559,10 +552,16 @@ textarea {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.no_itens {
|
||||
.no_itens, .see_all {
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.box .see_all {
|
||||
font-size: 11px;
|
||||
background-image: none;
|
||||
border-bottom-width: 0px;
|
||||
}
|
||||
|
||||
|
||||
.history input {
|
||||
margin: 0px 10px 0px 0px;
|
||||
@@ -889,6 +888,12 @@ ul.nested li {
|
||||
padding: 0px 0px 0px 18px;
|
||||
}
|
||||
|
||||
.box li.show_all {
|
||||
background-image: none;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*body { background-image: url(<%= App.base_path %>/prototype/line.png); background-repeat: repeat; }
|
||||
html * { background-color: transparent !important; }*/
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
<h1>Disciplina</h1>
|
||||
<ul>
|
||||
<li><%= link_to "Visão Geral", course_url(@course) %></li>
|
||||
<li><%= link_to "Participantes", course_events_url(@course) %></li>
|
||||
<li><%= link_to "Notícias", course_news_url(@course) %></li>
|
||||
<li><%= link_to "Arquivos", course_attachments_url(@course) %></li>
|
||||
<li><%= link_to "Calendário", course_events_url(@course) %></li>
|
||||
<li><%= link_to "Notícias", course_news_url(@course) %></li>
|
||||
<li><%= link_to "Participantes", course_events_url(@course) %></li>
|
||||
<li><%= link_to "Páginas Wiki", course_wiki_url(@course) %></li>
|
||||
<li><%= link_to "Mudanças recentes", course_log_url(@course) %></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -15,3 +15,5 @@
|
||||
%dt
|
||||
%label{:for => 'wiki_page_description'} Descrição das alterações
|
||||
%dd= text_field('wiki_page', 'description', { :size => '80' })
|
||||
|
||||
%dt= check_box('wiki_page', 'front_page') + " Exibir página wiki na página inicial do curso"
|
||||
|
||||
16
app/views/wiki/index.html.haml
Normal file
16
app/views/wiki/index.html.haml
Normal file
@@ -0,0 +1,16 @@
|
||||
.cmd
|
||||
= action_icon 'add', 'Adicionar', new_course_wiki_instance_url(@course)
|
||||
|
||||
%h4.title= h(@course.full_name)
|
||||
%h1.title Páginas Wiki
|
||||
|
||||
.box.div_news
|
||||
- if !@course.wiki_pages.empty?
|
||||
%ul
|
||||
- @course.wiki_pages.find(:all, :order => 'title').each do |w|
|
||||
%li= link_to(w.title, course_wiki_instance_url(@course, w))
|
||||
|
||||
- else
|
||||
.box
|
||||
%ul
|
||||
%li.no_itens Nenhuma página wiki
|
||||
Reference in New Issue
Block a user