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?
@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 < ?)',
@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

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

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

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

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

@ -1,18 +1,19 @@
%h4.title= h(@course.full_name)
%h1.title Mudanças recentes
%table.log
%tr
%th Data
%th Usuário
%th Descrição
- @log_entries.each do |entry|
.box
%table
%tr
%td= entry.created_at.strftime("%d/%m/%y&nbsp;%H:%M:%S")
%td= link_to truncate(h(entry.user.display_name), 20), user_path(entry.user)
%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?
%th Data
%th Usuário
%th Descrição
- @log_entries.each do |entry|
%tr
%td= entry.created_at.strftime("%d/%m/%y&nbsp;%H:%M:%S")
%td= link_to truncate(h(entry.user.display_name), 20), user_path(entry.user)
%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
.cmd
@ -8,21 +10,22 @@
= auto_discovery_link_tag :rss, formatted_course_news_index_url(@course, :rss)
.news
- @course.news.each do |n|
.line{:class => 'new', :id => "news_#{n.id}"}
.cmd{:style => (n.id == params[:id].to_i ? '' : 'display: none')}
= action_icon 'edit', 'Editar', edit_course_news_url(@course, n)
= action_icon 'trash', 'Excluir', course_news_url(@course, n), :confirm => 'Tem certeza que deseja excluir?', :method => :delete
.left= n.timestamp.strftime("%d de %B")
%h4
= link_to h(n.title), course_news_url(@course, n)
%p{:style => (n.id == params[:id].to_i ? '' : 'display: none')}
= h(n.body)
- if @course.news.empty?
.box.div_news
- if !@course.news.empty?
%table
- @course.news.each do |n|
%tr[n]
%td.top.aright
= n.timestamp.strftime("%d&nbsp;de&nbsp;%B")
%td
.title= link_to h(n.title), course_news_url(@course, n)
.description{:style => (n.id == params[:id].to_i ? '' : 'display: none')}
.cmd
= action_icon 'edit', 'Editar', edit_course_news_url(@course, n)
= action_icon 'trash', 'Excluir', course_news_url(@course, n), :confirm => 'Tem certeza que deseja excluir?', :method => :delete
= h(n.body)
= "Sem descrição" if n.body.empty?
- else
.box
%ul
%li.grey Nenhuma notícia
%li.no_itens Nenhuma notícia

@ -254,9 +254,6 @@ body {
font-size: 24px;
}
.content p:first-child {
margin-top: 9px;
}
#innerwrapper_2column {
padding: 0em 0px 0em 208px;
@ -388,7 +385,7 @@ h4.title, h1.title {
margin: 18px 0px;
}
.box h3, .box th {
.box h3 {
line-height: 34px;
margin: 0px;
border-bottom: 1px solid #eee;
@ -408,37 +405,21 @@ h4.title, h1.title {
border-bottom: 1px solid #f4f4f4;
}
.div_calendario .date {
line-height: 36px;
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, .div_news table {
width: 100%;
}
.div_calendario .time {
padding-right: 1em;
width: 3em;
float: left;
.div_calendario table tr td, .div_news table tr td {
padding-top: 9px;
padding-bottom: 9px;
}
.div_calendario .description {
padding-left: 4em;
.div_calendario table tr td:first-child, .div_news table tr td:first-child {
padding-left: 18px;
}
.news {
margin-top: 18px;
.div_calendario .cmd, .div_news .cmd {
margin-top: -9px;
line-weigth: 9px;
}
@ -532,30 +513,6 @@ select {
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 {
@ -662,9 +619,6 @@ textarea {
border-top: 1px solid #bbb;
}
xbody { background-image: url(<%= App.base_path %>/prototype/line.png); }
xhtml * { background-color: transparent !important; }
.menu, .content, #location {
border-right: 2px solid #ddd;
border-bottom: 2px solid #ddd;
@ -741,38 +695,40 @@ text-align: center;
margin-top: -1px;
}
ul.log li {
/*.box ul li {
border-top: 1px solid #eee;
padding: 4px 0px 4px 15px;
padding: 9px 0px 9px 15px;
background-position: 0px 12px;
}
}*/
table.log {
margin-top: 18px;
.box table {
margin-bottom: 2px;
border-collapse: collapse;
/*width: 100%;*/
}
table.log td {
.box table td {
border-top: 1px solid #eee;
padding: 4px 12px;
}
table.log th {
.box table th {
padding: 4px 12px;
border-top: 1px solid #eee;
font-weight: normal;
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 {
margin: 18px 0px;
text-align: right;
}
.left { float: left !important; }
.right { float: right !important; }
.fieldWithErrors input, .fieldWithErrors textarea {
border: 2px solid #c00;
}
@ -795,6 +751,13 @@ table.log th {
#wiki_text h3 { font-size: 12px; }
#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 {
background-image: none;
padding: 0px;
@ -803,3 +766,24 @@ table.log th {
ul ul, ul ol, ol ul, ol ol {
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_attrs = {:class => 'day'}
@events.each do |e|
if e.date == d
if e.time == d
cell_attrs[:onclick] = "show_events('#{d.to_s}')"
cell_attrs[:class] = 'specialDay'
cell_text = link_to d.mday, "#"
@ -35,8 +35,8 @@
<div class="widget_events">
<ul>
<% @events.each do |e| -%>
<li style="display: none" class="event_item events_<%=e.date.to_s%>">
<%= link_to e.date.strftime("%d de %B"), course_event_url(@course, e) %>.
<li style="display: none" class="event_item events_<%=e.time.to_s%>">
<%= link_to e.time.strftime("%d de %B"), course_event_url(@course, e) %>.
<%= h(e.title) %>. <%= h(e.description) %>
</li>
<% end -%>

@ -2,6 +2,6 @@
.menu
%h1= "User"[].titleize
%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("Edit settings"[].titleize, settings_url)

@ -10,25 +10,26 @@
- form_tag diff_course_wiki_url(@course, @wiki_page), :method => :get do
%button{:type => "submit"}= "Comparar as versões selecionadas"
%table.log
%tr
%th.narrow &nbsp;
%th.narrow &nbsp;
%th Data
%th Usuário
%th Descrição
- @wiki_page.versions.reverse.each do |entry|
.box
%table
%tr
%td.narrow
%input{:type => "radio", :name => "from", :value => entry.version, :onclick => "history_from(#{entry.version})"}
%td.narrow
%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)) + ")"
%th.narrow &nbsp;
%th.narrow &nbsp;
%th Data
%th Usuário
%th Descrição
- @wiki_page.versions.reverse.each do |entry|
%tr
%td.narrow
%input{:type => "radio", :name => "from", :value => entry.version, :onclick => "history_from(#{entry.version})"}
%td.narrow
%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

@ -9,7 +9,7 @@
#
# 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|
t.string "file_name", :null => false
@ -38,7 +38,7 @@ ActiveRecord::Schema.define(:version => 28) do
create_table "events", :force => true do |t|
t.string "title", :null => false
t.date "date", :null => false
t.date "date"
t.datetime "time", :null => false
t.integer "created_by", :null => false
t.integer "course_id", :default => 0, :null => false

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

@ -17,7 +17,7 @@ String.send(:include, StringPortuguese)
old_verbose = $VERBOSE
$VERBOSE = nil
[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}::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)"

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