Mudancas no dashboard, calendario e noticias

master
Alinson S. Xavier 18 years ago
parent 9461dcaf66
commit 11473aa23a

@ -112,9 +112,9 @@ class UsersController < ApplicationController
unless @current_user.courses.empty? unless @current_user.courses.empty?
@news = News.find(:all, :conditions => [ 'receiver_id in (?)', @current_user.courses ], @news = News.find(:all, :conditions => [ 'receiver_id in (?)', @current_user.courses ],
:order => 'timestamp desc') :order => 'timestamp desc', :limit => 5)
@events = Event.find(:all, :conditions => [ 'course_id in (?) and (date > ?) and (date < ?)', @events = Event.find(:all, :conditions => [ 'course_id in (?) and (date > ?) and (date < ?)',
@current_user.courses, 1.day.ago, 14.days.from_now ], :order => 'date, time') @current_user.courses, 1.day.ago, 21.days.from_now ], :order => 'date')
end end
end end

@ -21,8 +21,8 @@ class Event < ActiveRecord::Base
courses.each do |course| courses.each do |course|
course.events.each do |user_event| course.events.each do |user_event|
event = Icalendar::Event.new event = Icalendar::Event.new
event.start = user_event.date event.start = user_event.time
event.end = user_event.date event.end = user_event.time
event.summary = "#{course.short_name}: #{user_event.title}" event.summary = "#{course.short_name}: #{user_event.title}"
event.description = user_event.description event.description = user_event.description
cal.add(event) cal.add(event)

@ -8,13 +8,14 @@
.box .box
%ul %ul
- if logged_in? - if logged_in?
- unless @current_user.courses.empty? %h3 Disciplinas Matriculadas
%h3 Disciplinas matriculadas - if @current_user.courses.empty?
- for course in @current_user.courses %li.no_itens Nenhuma disciplina matriculada
%li{highlight(course.id)} - for course in @current_user.courses
.right %li{highlight(course.id)}
= action_icon('subtract', 'Desmatricular-se', unenroll_course_url(course)) .right
= link_to h(course.full_name), course_url(course) = action_icon('subtract', 'Desmatricular-se', unenroll_course_url(course))
= link_to h(course.full_name), course_url(course)
- old_period = 0 - old_period = 0
- for course in @courses - for course in @courses

@ -6,12 +6,12 @@
%dd= text_field 'event', 'title' %dd= text_field 'event', 'title'
%dt %dt
%label{:for => "event_date"} Data %label{:for => "event_time"} Data
%dd= date_select 'event', 'date', :order => [:day, :month, :year] %dd= date_select 'event', 'time', :order => [:day, :month, :year]
%dt %dt
%label{:for => "event_time"} Horário %label{:for => "event_time"} Horário
%dd= time_select 'event', 'time' %dd= time_select 'event', 'time', { :minute_step => 5 }
%dt %dt
%label{:for => "event_description"} Descrição %label{:for => "event_description"} Descrição

@ -1,6 +1,8 @@
= javascript_include_tag 'events'
- cache do - cache do
- last_event = nil - last_date = nil
.cmd .cmd
= action_icon 'add', 'Adicionar evento', new_course_event_url = action_icon 'add', 'Adicionar evento', new_course_event_url
@ -9,31 +11,27 @@
%h1.title Calendário %h1.title Calendário
.box.div_calendario .box.div_calendario
- if !@events.empty?
- @events.each do |event| %table
- if last_event != event.date - @events.each do |event|
= "</ul></div>" if last_event %tr[event]
.date= event.date.strftime("%d de %B") %td.top.aright{:width => '1%'}
= "<div><ul>" = event.time.strftime("%d&nbsp;de&nbsp;%B") #unless event.time == last_date
%td.top{:width => '1%'}
%li[event] = event.time.strftime("%H:%M")
.time= event.time.strftime("%H:%M") %td.top
= link_to h(event.title), course_event_url(@course, event) .title=link_to h(event.title), course_event_url(@course, event)
.description{:style => (event.id == params[:id].to_i ? '' : 'display: none')}
%div.description{:style => (event.id == params[:id].to_i ? '' : 'display: none')} %div.cmd
%div.cmd{:style => "height: 27px; margin-top: -27px;"} = action_icon 'edit', 'Editar', edit_course_event_url(@course, event)
= action_icon 'edit', 'Editar', edit_course_event_url(@course, event) = action_icon 'trash', 'Excluir', course_event_url(@course, event), :confirm => 'Tem certeza que deseja excluir?', :method => :delete
= action_icon 'trash', 'Excluir', course_event_url(@course, event), :confirm => 'Tem certeza que deseja excluir?', :method => :delete = h(event.description)
= h(event.description) = "Sem descrição" if event.description.empty?
= "Sem descrição" if event.description.empty?
- last_date = event.time
- last_event = event.date - else
.box
= "</ul></div>" if !@events.empty? %ul
%li.no_itens Nenhum evento
- if @events.empty?
.box
%ul
%li.grey Nenhum evento
%br %br

@ -1,18 +1,19 @@
%h4.title= h(@course.full_name) %h4.title= h(@course.full_name)
%h1.title Mudanças recentes %h1.title Mudanças recentes
%table.log .box
%tr %table
%th Data
%th Usuário
%th Descrição
- @log_entries.each do |entry|
%tr %tr
%td= entry.created_at.strftime("%d/%m/%y&nbsp;%H:%M:%S") %th Data
%td= link_to truncate(h(entry.user.display_name), 20), user_path(entry.user) %th Usuário
%td %th Descrição
= render(:partial => 'log/attachment_log_entry', :locals => { :entry => entry }) if entry.kind_of?(AttachmentLogEntry) - @log_entries.each do |entry|
= render(:partial => 'log/event_log_entry', :locals => { :entry => entry }) if entry.kind_of?(EventLogEntry) %tr
= render(:partial => 'log/news_log_entry', :locals => { :entry => entry }) if entry.kind_of?(NewsLogEntry) %td= entry.created_at.strftime("%d/%m/%y&nbsp;%H:%M:%S")
= render(:partial => 'log/wiki_log_entry', :locals => { :entry => entry }) if entry.kind_of?(WikiLogEntry) %td= link_to truncate(h(entry.user.display_name), 20), user_path(entry.user)
= "(" + link_to("undo", undo_course_log_url(@course, entry)) + ")" if entry.reversible? %td
= render(:partial => 'log/attachment_log_entry', :locals => { :entry => entry }) if entry.kind_of?(AttachmentLogEntry)
= render(:partial => 'log/event_log_entry', :locals => { :entry => entry }) if entry.kind_of?(EventLogEntry)
= render(:partial => 'log/news_log_entry', :locals => { :entry => entry }) if entry.kind_of?(NewsLogEntry)
= render(:partial => 'log/wiki_log_entry', :locals => { :entry => entry }) if entry.kind_of?(WikiLogEntry)
= "(" + link_to("undo", undo_course_log_url(@course, entry)) + ")" if entry.reversible?

@ -1,3 +1,5 @@
= javascript_include_tag 'news'
- cache do - cache do
.cmd .cmd
@ -8,21 +10,22 @@
= auto_discovery_link_tag :rss, formatted_course_news_index_url(@course, :rss) = auto_discovery_link_tag :rss, formatted_course_news_index_url(@course, :rss)
.news .box.div_news
- @course.news.each do |n| - if !@course.news.empty?
.line{:class => 'new', :id => "news_#{n.id}"} %table
.cmd{:style => (n.id == params[:id].to_i ? '' : 'display: none')} - @course.news.each do |n|
= action_icon 'edit', 'Editar', edit_course_news_url(@course, n) %tr[n]
= action_icon 'trash', 'Excluir', course_news_url(@course, n), :confirm => 'Tem certeza que deseja excluir?', :method => :delete %td.top.aright
= n.timestamp.strftime("%d&nbsp;de&nbsp;%B")
.left= n.timestamp.strftime("%d de %B") %td
%h4 .title= link_to h(n.title), course_news_url(@course, n)
= link_to h(n.title), course_news_url(@course, n) .description{:style => (n.id == params[:id].to_i ? '' : 'display: none')}
.cmd
%p{:style => (n.id == params[:id].to_i ? '' : 'display: none')} = action_icon 'edit', 'Editar', edit_course_news_url(@course, n)
= h(n.body) = action_icon 'trash', 'Excluir', course_news_url(@course, n), :confirm => 'Tem certeza que deseja excluir?', :method => :delete
= h(n.body)
- if @course.news.empty? = "Sem descrição" if n.body.empty?
- else
.box .box
%ul %ul
%li.grey Nenhuma notícia %li.no_itens Nenhuma notícia

@ -254,9 +254,6 @@ body {
font-size: 24px; font-size: 24px;
} }
.content p:first-child {
margin-top: 9px;
}
#innerwrapper_2column { #innerwrapper_2column {
padding: 0em 0px 0em 208px; padding: 0em 0px 0em 208px;
@ -388,7 +385,7 @@ h4.title, h1.title {
margin: 18px 0px; margin: 18px 0px;
} }
.box h3, .box th { .box h3 {
line-height: 34px; line-height: 34px;
margin: 0px; margin: 0px;
border-bottom: 1px solid #eee; border-bottom: 1px solid #eee;
@ -408,37 +405,21 @@ h4.title, h1.title {
border-bottom: 1px solid #f4f4f4; border-bottom: 1px solid #f4f4f4;
} }
.div_calendario .date { .div_calendario table, .div_news table {
line-height: 36px; width: 100%;
width: 105px;
text-align: right;
float: left;
}
.div_calendario ul {
padding-left: 115px;
margin-top: -1px;
margin-bottom: 0em;
border-top: 1px solid #eee;
list-style: none !important;
}
.div_calendario li {
border-bottom: 1px solid #eee;
} }
.div_calendario table tr td, .div_news table tr td {
.div_calendario .time { padding-top: 9px;
padding-right: 1em; padding-bottom: 9px;
width: 3em;
float: left;
} }
.div_calendario .description { .div_calendario table tr td:first-child, .div_news table tr td:first-child {
padding-left: 4em; padding-left: 18px;
} }
.news { .div_calendario .cmd, .div_news .cmd {
margin-top: 18px; margin-top: -9px;
line-weigth: 9px;
} }
@ -532,30 +513,6 @@ select {
margin-top: 9px; margin-top: 9px;
} }
.news .left {
float: left;
line-height: 18px;
margin: 0px;
width: 105px;
padding-top: 8px;
padding-right: 15px;
text-align: right;
}
.news h4 {
margin: 8px 0px;
padding: 0px;
}
.news p {
padding-left: 120px;
margin-top: 8px;
}
.news .line {
border-top: 1px solid #eee;
margin-bottom: 9px;
}
.history { .history {
@ -662,9 +619,6 @@ textarea {
border-top: 1px solid #bbb; border-top: 1px solid #bbb;
} }
xbody { background-image: url(<%= App.base_path %>/prototype/line.png); }
xhtml * { background-color: transparent !important; }
.menu, .content, #location { .menu, .content, #location {
border-right: 2px solid #ddd; border-right: 2px solid #ddd;
border-bottom: 2px solid #ddd; border-bottom: 2px solid #ddd;
@ -741,38 +695,40 @@ text-align: center;
margin-top: -1px; margin-top: -1px;
} }
ul.log li { /*.box ul li {
border-top: 1px solid #eee; border-top: 1px solid #eee;
padding: 4px 0px 4px 15px; padding: 9px 0px 9px 15px;
background-position: 0px 12px; background-position: 0px 12px;
} }*/
table.log { .box table {
margin-top: 18px; margin-bottom: 2px;
border-collapse: collapse; border-collapse: collapse;
/*width: 100%;*/
} }
table.log td { .box table td {
border-top: 1px solid #eee; border-top: 1px solid #eee;
padding: 4px 12px; padding: 4px 12px;
} }
table.log th { .box table th {
padding: 4px 12px; padding: 4px 12px;
border-top: 1px solid #eee; border-top: 1px solid #eee;
font-weight: normal; font-weight: normal;
text-align: left; text-align: left;
} }
.top { vertical-align: top; }
.center { text-align: center !important; }
.left { float: left !important; }
.right { float: right !important; }
.aright { text-align: right !important; }
.pagination { .pagination {
margin: 18px 0px; margin: 18px 0px;
text-align: right; text-align: right;
} }
.left { float: left !important; }
.right { float: right !important; }
.fieldWithErrors input, .fieldWithErrors textarea { .fieldWithErrors input, .fieldWithErrors textarea {
border: 2px solid #c00; border: 2px solid #c00;
} }
@ -795,6 +751,13 @@ table.log th {
#wiki_text h3 { font-size: 12px; } #wiki_text h3 { font-size: 12px; }
#wiki_text h4, #wiki_text h5, #wiki_text h6 { font-size: 11px; } #wiki_text h4, #wiki_text h5, #wiki_text h6 { font-size: 11px; }
.box h3. {
margin-bottom: -9px;
margin-top: 18px;
padding-top: 9px;
font-weight: normal;
}
.content ol li { .content ol li {
background-image: none; background-image: none;
padding: 0px; padding: 0px;
@ -803,3 +766,24 @@ table.log th {
ul ul, ul ol, ol ul, ol ol { ul ul, ul ol, ol ul, ol ol {
margin: 0px; margin: 0px;
} }
li p, td p {
margin-top: 0px;
}
.dashboard td:first-child {
padding-left: 27px;
}
.dashboard table tr td {
padding-right: 9px;
}
.dashboard .box ul {
margin-bottom: 0px;
}
xbody { background-image: url(<%= App.base_path %>/prototype/line.png); background-repeat: repeat; }
xhtml * { background-color: transparent !important; }

@ -1,49 +0,0 @@
<% last_event = nil %>
<h4 class="title">Dashboard</h4>
<h1 class="title">Bem vindo, <%= h(@current_user.display_name) %></h1>
<!-- Noticias -->
<div class="news box">
<h3>Notícias recentes</h3>
<% @news.each do |n| %>
<div class="line">
<h4 class="left"><%= n.timestamp.strftime("%d de %B") %></h4>
<h4><%= link_to h(n.course.full_name) , course_url(n.course) %> &rsaquo;
<%= link_to h(n.title), course_news_url(n.course, n) %></h4>
</div>
<% end %>
</div>
<!-- Calendario -->
<div class="box div_calendario">
<h3>Próximos eventos</h3>
<% @events.each do |event| %>
<% if last_event != event.date %>
<% if last_event %></ul></div><% end %>
<div class="date"><%= event.date.strftime("%d de %B") %></div>
<div><ul>
<% end %>
<li>
<div class="time"><%= event.time.strftime("%H:%M") %></div>
<%= link_to h(event.course.full_name), course_url(event.course) %> &rsaquo;
<%= link_to h(event.title), course_event_url(event.course, event) %>
</li>
<% last_event = event.date %>
<% end %>
<%= "</ul></div>" if !@events.empty? %>
</div>
<!-- Disciplinas Matriculadas -->
<div class="box">
<h3>Disciplinas Matriculadas</h3>
<ul class="wiki">
<% @current_user.courses.each do |course| %>
<li><%= link_to h(course.full_name), course_url(course) %></li>
<% end %>
</ul>
</div>
<h4><%#= link_to 'Descadastrar usuário', :action => 'destroy'%></h4>

@ -21,7 +21,7 @@
cell_text = d.mday cell_text = d.mday
cell_attrs = {:class => 'day'} cell_attrs = {:class => 'day'}
@events.each do |e| @events.each do |e|
if e.date == d if e.time == d
cell_attrs[:onclick] = "show_events('#{d.to_s}')" cell_attrs[:onclick] = "show_events('#{d.to_s}')"
cell_attrs[:class] = 'specialDay' cell_attrs[:class] = 'specialDay'
cell_text = link_to d.mday, "#" cell_text = link_to d.mday, "#"
@ -35,8 +35,8 @@
<div class="widget_events"> <div class="widget_events">
<ul> <ul>
<% @events.each do |e| -%> <% @events.each do |e| -%>
<li style="display: none" class="event_item events_<%=e.date.to_s%>"> <li style="display: none" class="event_item events_<%=e.time.to_s%>">
<%= link_to e.date.strftime("%d de %B"), course_event_url(@course, e) %>. <%= link_to e.time.strftime("%d de %B"), course_event_url(@course, e) %>.
<%= h(e.title) %>. <%= h(e.description) %> <%= h(e.title) %>. <%= h(e.description) %>
</li> </li>
<% end -%> <% end -%>

@ -2,6 +2,6 @@
.menu .menu
%h1= "User"[].titleize %h1= "User"[].titleize
%ul %ul
/%li= link_to "Dashboard"[].titleize, dashboard_path %li= link_to "Dashboard"[].titleize, dashboard_path
%li= link_to("User profile"[].titleize, user_url(@current_user)) %li= link_to("User profile"[].titleize, user_url(@current_user))
%li= link_to("Edit settings"[].titleize, settings_url) %li= link_to("Edit settings"[].titleize, settings_url)

@ -10,25 +10,26 @@
- form_tag diff_course_wiki_url(@course, @wiki_page), :method => :get do - form_tag diff_course_wiki_url(@course, @wiki_page), :method => :get do
%button{:type => "submit"}= "Comparar as versões selecionadas" %button{:type => "submit"}= "Comparar as versões selecionadas"
%table.log .box
%tr %table
%th.narrow &nbsp;
%th.narrow &nbsp;
%th Data
%th Usuário
%th Descrição
- @wiki_page.versions.reverse.each do |entry|
%tr %tr
%td.narrow %th.narrow &nbsp;
%input{:type => "radio", :name => "from", :value => entry.version, :onclick => "history_from(#{entry.version})"} %th.narrow &nbsp;
%td.narrow %th Data
%input{:type => "radio", :name => "to", :value => entry.version, :onclick => %"history_to(#{entry.version})"} %th Usuário
%td= link_to(entry.updated_at.strftime("%d/%m/%y&nbsp;%H:%M:%S"), course_wiki_url(@course, @wiki_page, :version => entry.version)) %th Descrição
%td= link_to truncate(h(entry.user.display_name), 20), user_path(entry.user) - @wiki_page.versions.reverse.each do |entry|
%td %tr
= entry.description %td.narrow
- if (entry.version > @wiki_page.versions.minimum(:version)) %input{:type => "radio", :name => "from", :value => entry.version, :onclick => "history_from(#{entry.version})"}
= "(" + link_to("diff", diff_course_wiki_url(@course, @wiki_page, :from => entry.version - 1, :to => entry.version)) + ")" %td.narrow
= "(" + link_to("edit", edit_course_wiki_url(@course, @wiki_page, :description => "Revertendo para versão #{entry.version}", :version => entry.version)) + ")" %input{:type => "radio", :name => "to", :value => entry.version, :onclick => %"history_to(#{entry.version})"}
%td= link_to(entry.updated_at.strftime("%d/%m/%y&nbsp;%H:%M:%S"), course_wiki_url(@course, @wiki_page, :version => entry.version))
%td= link_to truncate(h(entry.user.display_name), 20), user_path(entry.user)
%td
= entry.description
- if (entry.version > @wiki_page.versions.minimum(:version))
= "(" + link_to("diff", diff_course_wiki_url(@course, @wiki_page, :from => entry.version - 1, :to => entry.version)) + ")"
= "(" + link_to("edit", edit_course_wiki_url(@course, @wiki_page, :description => "Revertendo para versão #{entry.version}", :version => entry.version)) + ")"
/= will_paginate @versions /= will_paginate @versions

@ -9,7 +9,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 28) do ActiveRecord::Schema.define(:version => 29) do
create_table "attachments", :force => true do |t| create_table "attachments", :force => true do |t|
t.string "file_name", :null => false t.string "file_name", :null => false
@ -38,7 +38,7 @@ ActiveRecord::Schema.define(:version => 28) do
create_table "events", :force => true do |t| create_table "events", :force => true do |t|
t.string "title", :null => false t.string "title", :null => false
t.date "date", :null => false t.date "date"
t.datetime "time", :null => false t.datetime "time", :null => false
t.integer "created_by", :null => false t.integer "created_by", :null => false
t.integer "course_id", :default => 0, :null => false t.integer "course_id", :default => 0, :null => false

@ -57,7 +57,7 @@ module AuthenticationSystem
session[:return_to] = nil session[:return_to] = nil
redirect_to return_to redirect_to return_to
else else
redirect_to index_url redirect_to dashboard_url
end end
end end

@ -17,7 +17,7 @@ String.send(:include, StringPortuguese)
old_verbose = $VERBOSE old_verbose = $VERBOSE
$VERBOSE = nil $VERBOSE = nil
[Time, Date].each do |clazz| [Time, Date].each do |clazz|
eval "#{clazz}::MONTHNAMES = [nil] + %w(Janeiro Fevereiro Marco Abril Maio Junho Julho Agosto Setembro Outubro Novembro Dezembro)" eval "#{clazz}::MONTHNAMES = [nil] + %w(Janeiro Fevereiro Março Abril Maio Junho Julho Agosto Setembro Outubro Novembro Dezembro)"
eval "#{clazz}::DAYNAMES = %w(Domingo Segunda-Feira Terca-Feira Quarta-Feira Quinta-Feira Sexta-Feira Sabado)" eval "#{clazz}::DAYNAMES = %w(Domingo Segunda-Feira Terca-Feira Quarta-Feira Quinta-Feira Sexta-Feira Sabado)"
eval "#{clazz}::ABBR_MONTHNAMES = [nil] + %w(Jan Fev Mar Abr Mai Jun Jul Ago Set Out Nov Dez)" eval "#{clazz}::ABBR_MONTHNAMES = [nil] + %w(Jan Fev Mar Abr Mai Jun Jul Ago Set Out Nov Dez)"
eval "#{clazz}::ABBR_DAYNAMES = %w(Dom Seg Ter Qua Qui Sex Sab)" eval "#{clazz}::ABBR_DAYNAMES = %w(Dom Seg Ter Qua Qui Sex Sab)"

@ -16,7 +16,7 @@ class TimeTest < Test::Unit::TestCase
assert_equal [nil, assert_equal [nil,
"Janeiro", "Janeiro",
"Fevereiro", "Fevereiro",
"Marco", "Março",
"Abril", "Abril",
"Maio", "Maio",
"Junho", "Junho",