Refactor courses
This commit is contained in:
@@ -23,64 +23,67 @@ require 'yaml'
|
|||||||
require 'authentication.rb'
|
require 'authentication.rb'
|
||||||
|
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
helper :all
|
helper :all
|
||||||
protect_from_forgery
|
protect_from_forgery
|
||||||
|
|
||||||
include AuthenticationSystem
|
include AuthenticationSystem
|
||||||
|
|
||||||
before_filter :startup
|
before_filter :startup
|
||||||
#before_filter :set_timezone
|
# before_filter :set_timezone
|
||||||
before_filter :require_login, :only => [ :edit, :new, :create, :update, :delete, :destroy ]
|
before_filter :require_login, only: [:edit, :new, :create, :update, :delete,
|
||||||
|
:destroy]
|
||||||
|
|
||||||
protected
|
rescue_from AccessDenied, with: :deny_access
|
||||||
def rescue_action(exception)
|
rescue_from ActiveRecord::RecordInvalid, with: :reshow_form
|
||||||
# Acesso negado
|
rescue_from ActiveRecord::RecordNotFound, with: :show_not_found
|
||||||
if exception.is_a?(AccessDenied)
|
|
||||||
respond_to do |format|
|
|
||||||
format.html {
|
|
||||||
if logged_in?
|
|
||||||
render :file => "#{Rails.root}/public/401.html", :status => 401
|
|
||||||
else
|
|
||||||
login_by_html
|
|
||||||
end
|
|
||||||
}
|
|
||||||
format.xml { head 401 }
|
|
||||||
end
|
|
||||||
|
|
||||||
# Erro de validacao
|
protected
|
||||||
elsif exception.is_a?(ActiveRecord::RecordInvalid)
|
|
||||||
respond_to do |format|
|
|
||||||
format.html { render :action => (params[:from].nil? ? (exception.record.new_record? ? 'new' : 'edit') : params[:from]) }
|
|
||||||
format.xml { render :xml => exception.record.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
|
|
||||||
# Registro nao encontrado
|
def deny_access
|
||||||
elsif (RAILS_ENV == 'production') and exception.is_a?(ActiveRecord::RecordNotFound)
|
respond_to do |format|
|
||||||
respond_to do |format|
|
format.html do
|
||||||
format.html { render :file => "#{Rails.root}/public/404.html", :status => 404 }
|
if logged_in?
|
||||||
format.xml { head 404 }
|
render file: "#{Rails.root}/public/401.html", status: 401
|
||||||
end
|
else
|
||||||
|
login_by_html
|
||||||
|
end
|
||||||
|
end
|
||||||
|
format.xml { head 401 }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Outras excecoes
|
def reshow_form(exception)
|
||||||
else
|
respond_to do |format|
|
||||||
super
|
format.html { render action: (params[:from].nil? ? (exception.record.new_record? ? 'new' : 'edit') : params[:from]) }
|
||||||
end
|
format.xml { render xml: exception.record.errors, status: :unprocessable_entity }
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
#def set_timezone
|
def show_not_found
|
||||||
# #Time.zone = session[:user].tz
|
if (RAILS_ENV == 'production')
|
||||||
# Time.zone = "America/Fortaleza"
|
respond_to do |format|
|
||||||
#end
|
format.html { render file: "#{Rails.root}/public/404.html", status: 404 }
|
||||||
|
format.xml { head 404 }
|
||||||
|
end
|
||||||
|
else
|
||||||
|
fail ActiveRecord::RecordNotFound
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def startup
|
# def set_timezone
|
||||||
if session[:user_id]
|
# #Time.zone = session[:user].tz
|
||||||
@current_user = User.find(session[:user_id])
|
# Time.zone = "America/Fortaleza"
|
||||||
else
|
# end
|
||||||
login_by_token
|
|
||||||
end
|
|
||||||
|
|
||||||
@color = App.default_color
|
def startup
|
||||||
@color = @current_user.pref_color if @current_user
|
if session[:user_id]
|
||||||
@color = params[:color].to_i if params[:color]
|
@current_user = User.find(session[:user_id])
|
||||||
end
|
else
|
||||||
|
login_by_token
|
||||||
|
end
|
||||||
|
|
||||||
|
@color = App.default_color
|
||||||
|
@color = @current_user.pref_color if @current_user
|
||||||
|
@color = params[:color].to_i if params[:color]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,35 +20,26 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
class CoursesController < ApplicationController
|
class CoursesController < ApplicationController
|
||||||
|
before_filter :require_admin, only: [:new, :create, :edit, :update,
|
||||||
before_filter :require_admin, :only => [:new, :create, :edit, :update, :destroy]
|
:destroy]
|
||||||
before_filter :require_login, :only => [:enroll, :unenroll]
|
before_filter :require_login, only: [:enroll, :unenroll]
|
||||||
before_filter :find_course, :except => [:index]
|
before_filter :find_course, except: [:index]
|
||||||
#after_filter :cache_sweep, :only => [ :create, :update, :destroy ]
|
# after_filter :cache_sweep, only: [ :create, :update, :destroy ]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
params[:period] = nil if params[:period] == App.current_period
|
|
||||||
@period = params[:period] || App.current_period
|
@period = params[:period] || App.current_period
|
||||||
|
@courses = Course.visible.where(period: @period)
|
||||||
if logged_in? and !@current_user.courses.empty?
|
|
||||||
@courses = Course.all(:order => 'grade asc, full_name asc',
|
|
||||||
:conditions => ['period = ? and hidden = ? and id not in (?)',
|
|
||||||
@period, false, @current_user.courses])
|
|
||||||
else
|
|
||||||
@courses = Course.all(:order => 'grade asc, full_name asc',
|
|
||||||
:conditions => ['period = ? and hidden = ?', @period, false])
|
|
||||||
end
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.xml { render :xml => @courses }
|
format.xml { render xml: @courses }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.xml { render :xml => @course }
|
format.xml { render xml: @course }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -61,8 +52,9 @@ class CoursesController < ApplicationController
|
|||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to course_path(@course) }
|
format.html { redirect_to course_path(@course) }
|
||||||
format.xml { head :created, :location => course_url(@course,
|
format.xml do
|
||||||
:format => :xml) }
|
head :created, location: course_url(@course, format: :xml)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -111,19 +103,21 @@ class CoursesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def find_course
|
def find_course
|
||||||
if params[:id]
|
if params[:id]
|
||||||
params[:id] = Course.first(:conditions => ['short_name = ?', params[:id]], :order => 'period desc').id if !params[:id].is_numeric? and !Course.find_by_short_name(params[:id]).nil?
|
@course = Course.from_param(params[:id])
|
||||||
|
else
|
||||||
|
@course = Course.new(params[:course])
|
||||||
end
|
end
|
||||||
@course = params[:id] ? Course.find(params[:id]) : Course.new(params[:course])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def require_admin
|
def require_admin
|
||||||
raise AccessDenied.new unless admin?
|
fail AccessDenied, 'only admins can modify courses' unless admin?
|
||||||
end
|
end
|
||||||
|
|
||||||
def cache_sweep
|
def cache_sweep
|
||||||
expire_fragment(course_path(@course.id, :part => 'right'))
|
expire_fragment(course_path(@course.id, part: 'right'))
|
||||||
expire_fragment(course_path(@course.id))
|
expire_fragment(course_path(@course.id))
|
||||||
expire_fragment(courses_path)
|
expire_fragment(courses_path)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ module AttachmentsHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def nest_path(items, paths, from, to, level)
|
def nest_path(items, paths, from, to, level)
|
||||||
result = {}
|
result = { }
|
||||||
|
|
||||||
base = from - 1
|
base = from - 1
|
||||||
base = base + 1 while base+1 <= to and paths[base+1][level].nil?
|
base = base + 1 while base+1 <= to and paths[base+1][level].nil?
|
||||||
|
|||||||
@@ -20,64 +20,70 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
class Course < ActiveRecord::Base
|
class Course < ActiveRecord::Base
|
||||||
|
|
||||||
acts_as_paranoid
|
acts_as_paranoid
|
||||||
|
|
||||||
|
default_scope order('grade asc, full_name asc, period desc')
|
||||||
|
|
||||||
|
scope :visible, where(hidden: false)
|
||||||
|
|
||||||
has_many :attachments,
|
has_many :attachments,
|
||||||
:order => 'path is not null, path, file_name',
|
order: 'path is not null, path, file_name',
|
||||||
:dependent => :destroy
|
dependent: :destroy
|
||||||
|
|
||||||
has_many :events,
|
has_many :events,
|
||||||
:order => 'time asc',
|
order: 'time asc',
|
||||||
:dependent => :destroy
|
dependent: :destroy
|
||||||
|
|
||||||
has_many :news,
|
has_many :news,
|
||||||
:foreign_key => 'receiver_id',
|
foreign_key: 'receiver_id',
|
||||||
:order => 'id desc',
|
order: 'id desc',
|
||||||
:class_name => 'News',
|
class_name: 'News',
|
||||||
:dependent => :destroy
|
dependent: :destroy
|
||||||
|
|
||||||
has_many :log_entries,
|
has_many :log_entries,
|
||||||
:order => 'created_at desc',
|
order: 'created_at desc',
|
||||||
:dependent => :destroy
|
dependent: :destroy
|
||||||
|
|
||||||
has_many :wiki_pages,
|
has_many :wiki_pages,
|
||||||
:order => 'position',
|
order: 'position',
|
||||||
:dependent => :destroy
|
dependent: :destroy
|
||||||
|
|
||||||
has_and_belongs_to_many :users,
|
has_and_belongs_to_many :users,
|
||||||
:order => 'last_seen desc'
|
order: 'last_seen desc'
|
||||||
|
|
||||||
validates_presence_of :short_name
|
validates_presence_of :short_name
|
||||||
validates_presence_of :full_name
|
validates_presence_of :full_name
|
||||||
validates_presence_of :code
|
validates_presence_of :code
|
||||||
validates_numericality_of :grade, :only_integer => true
|
validates_numericality_of :grade, only_integer: true
|
||||||
validates_inclusion_of :hidden, :in => [true, false], :allow_nil => false
|
validates_inclusion_of :hidden, in: [true, false], allow_nil: false
|
||||||
validates_format_of :short_name, :with => /^[^0-9]/
|
validates_format_of :short_name, with: /^[^0-9]/
|
||||||
|
|
||||||
after_create :add_initial_wiki_pages
|
after_create :add_initial_wiki_pages
|
||||||
|
|
||||||
def related_courses
|
def related_courses
|
||||||
Course.all(:conditions => ['short_name = ?', self.short_name], :limit => 4,
|
Course.all(conditions: ['short_name = ?', short_name], limit: 4,
|
||||||
:order => 'period desc')
|
order: 'period desc')
|
||||||
end
|
end
|
||||||
|
|
||||||
def recent_news
|
def recent_news
|
||||||
self.news.all(:conditions => ['timestamp > ?', 7.days.ago])
|
news.all(conditions: ['timestamp > ?', 7.days.ago])
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_initial_wiki_pages
|
def add_initial_wiki_pages
|
||||||
App.initial_wiki_pages.each do |page_title|
|
App.initial_wiki_pages.each do |page_title|
|
||||||
wiki_page = WikiPage.new(:title => page_title, :description => 'New course',
|
wiki_page = WikiPage.new(title: page_title, description: 'New course',
|
||||||
:content => App.initial_wiki_page_content)
|
content: App.initial_wiki_page_content)
|
||||||
wiki_page.user = User.first
|
wiki_page.user = User.first
|
||||||
self.wiki_pages << wiki_page
|
wiki_pages << wiki_page
|
||||||
wiki_page.save!
|
wiki_page.save!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_param
|
def to_param
|
||||||
return self.short_name if self.period == App.current_period
|
period == App.current_period ? short_name : id.to_s
|
||||||
return self.id.to_s
|
end
|
||||||
|
|
||||||
|
def self.from_param(param)
|
||||||
|
param.is_numeric? ? Course.find(param) : Course.find_by_short_name(param)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
5
app/models/coverage/.last_run.json
Normal file
5
app/models/coverage/.last_run.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"result": {
|
||||||
|
"covered_percent": 3.57
|
||||||
|
}
|
||||||
|
}
|
||||||
0
app/models/coverage/.resultset.json.lock
Normal file
0
app/models/coverage/.resultset.json.lock
Normal file
@@ -20,21 +20,28 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
class AttachmentLogEntry < LogEntry
|
class AttachmentLogEntry < LogEntry
|
||||||
belongs_to :attachment,
|
belongs_to :attachment,
|
||||||
:foreign_key => "target_id",
|
:foreign_key => "target_id",
|
||||||
:with_deleted => true
|
:with_deleted => true
|
||||||
end
|
end
|
||||||
|
|
||||||
class AttachmentDeleteLogEntry < AttachmentLogEntry
|
class AttachmentDeleteLogEntry < AttachmentLogEntry
|
||||||
def reversible?()
|
def reversible?()
|
||||||
attachment.deleted?
|
attachment.deleted?
|
||||||
end
|
end
|
||||||
def undo!(current_user)
|
|
||||||
attachment.update_attribute(:deleted_at, nil)
|
def undo!(current_user)
|
||||||
AttachmentRestoreLogEntry.create!(:target_id => attachment.id, :user_id => current_user.id, :course => attachment.course)
|
attachment.update_attribute(:deleted_at, nil)
|
||||||
end
|
AttachmentRestoreLogEntry.create!(:target_id => attachment.id,
|
||||||
|
:user_id => current_user.id, :course => attachment.course)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class AttachmentEditLogEntry < AttachmentLogEntry; end
|
class AttachmentEditLogEntry < AttachmentLogEntry
|
||||||
class AttachmentCreateLogEntry < AttachmentLogEntry; end
|
end
|
||||||
class AttachmentRestoreLogEntry < AttachmentLogEntry; end
|
|
||||||
|
class AttachmentCreateLogEntry < AttachmentLogEntry
|
||||||
|
end
|
||||||
|
|
||||||
|
class AttachmentRestoreLogEntry < AttachmentLogEntry
|
||||||
|
end
|
||||||
|
|||||||
@@ -20,21 +20,27 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
class EventLogEntry < LogEntry
|
class EventLogEntry < LogEntry
|
||||||
belongs_to :event,
|
belongs_to :event,
|
||||||
:foreign_key => "target_id",
|
:foreign_key => "target_id",
|
||||||
:with_deleted => true
|
:with_deleted => true
|
||||||
end
|
end
|
||||||
|
|
||||||
class EventDeleteLogEntry < EventLogEntry
|
class EventDeleteLogEntry < EventLogEntry
|
||||||
def reversible?()
|
def reversible?()
|
||||||
event.deleted?
|
event.deleted?
|
||||||
end
|
end
|
||||||
def undo!(current_user)
|
|
||||||
event.recover!
|
def undo!(current_user)
|
||||||
EventRestoreLogEntry.create!(:target_id => event.id, :user_id => current_user.id, :course => event.course, :version => event.version)
|
event.recover!
|
||||||
end
|
EventRestoreLogEntry.create!(:target_id => event.id, :user_id => current_user.id, :course => event.course, :version => event.version)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class EventEditLogEntry < EventLogEntry; end
|
class EventEditLogEntry < EventLogEntry
|
||||||
class EventCreateLogEntry < EventLogEntry; end
|
end
|
||||||
class EventRestoreLogEntry < EventLogEntry; end
|
|
||||||
|
class EventCreateLogEntry < EventLogEntry
|
||||||
|
end
|
||||||
|
|
||||||
|
class EventRestoreLogEntry < EventLogEntry
|
||||||
|
end
|
||||||
|
|||||||
@@ -22,100 +22,102 @@
|
|||||||
require 'digest/sha1'
|
require 'digest/sha1'
|
||||||
|
|
||||||
class User < ActiveRecord::Base
|
class User < ActiveRecord::Base
|
||||||
|
acts_as_paranoid
|
||||||
|
|
||||||
# Plugins
|
has_and_belongs_to_many :courses, order: 'full_name',
|
||||||
acts_as_paranoid
|
conditions: "period = #{App.current_period}"
|
||||||
|
|
||||||
# Associacoes
|
validates_length_of :login, within: 3..40
|
||||||
has_and_belongs_to_many :courses, :order => 'full_name', :conditions => "period = #{App.current_period}"
|
validates_length_of :name, within: 3..40
|
||||||
|
validates_length_of :display_name, within: 3..40
|
||||||
|
|
||||||
# Validacao
|
validates_presence_of :login, :email, :display_name
|
||||||
validates_length_of :login, :within => 3..40
|
validates_uniqueness_of :login, :email, :display_name
|
||||||
validates_length_of :name, :within => 3..40
|
|
||||||
validates_length_of :display_name, :within => 3..40
|
|
||||||
|
|
||||||
validates_presence_of :login, :email, :display_name
|
validates_format_of :login, with: /^[^0-9]/
|
||||||
validates_uniqueness_of :login, :email, :display_name
|
validates_format_of :display_name, with: /^[^0-9]/
|
||||||
|
|
||||||
validates_format_of :login, :with => /^[^0-9]/
|
validates_format_of :email,
|
||||||
validates_format_of :display_name, :with => /^[^0-9]/
|
with: /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
|
||||||
|
|
||||||
validates_format_of :email,
|
attr_protected :id, :salt
|
||||||
:with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
|
attr_accessor :password, :password_confirmation
|
||||||
|
|
||||||
# Seguranca
|
def self.find_by_login_and_pass(login, pass)
|
||||||
attr_protected :id, :salt
|
user = find(:first, conditions: ['login = ?', login])
|
||||||
attr_accessor :password, :password_confirmation
|
(!user.nil? && User.encrypt(pass, user.salt) == user.hashed_password) ? user : nil
|
||||||
|
end
|
||||||
|
|
||||||
def User.find_by_login_and_pass(login, pass)
|
def to_xml(options = {})
|
||||||
user = find(:first, :conditions => [ "login = ?", login ])
|
options[:indent] ||= 2
|
||||||
return (!user.nil? and User.encrypt(pass, user.salt) == user.hashed_password) ? user : nil
|
xml = options[:builder] ||= Builder::XmlMarkup.new(indent: options[:indent])
|
||||||
end
|
xml.instruct! unless options[:skip_instruct]
|
||||||
|
xml.user do
|
||||||
|
xml.id id
|
||||||
|
xml.name name
|
||||||
|
xml.display_name display_name
|
||||||
|
xml.login login
|
||||||
|
xml.created_at created_at
|
||||||
|
xml.last_seen last_seen
|
||||||
|
xml.description description
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def to_xml(options = {})
|
# Gera uma nova senha, e a envia por email.
|
||||||
options[:indent] ||= 2
|
def generate_password_reset_key!
|
||||||
xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
|
update_attribute(:password_reset_key, User.random_string(30))
|
||||||
xml.instruct! unless options[:skip_instruct]
|
save!
|
||||||
xml.user do
|
Notifications.deliver_forgot_password(email, password_reset_key)
|
||||||
xml.id self.id
|
end
|
||||||
xml.name self.name
|
|
||||||
xml.display_name self.display_name
|
|
||||||
xml.login self.login
|
|
||||||
xml.created_at self.created_at
|
|
||||||
xml.last_seen self.last_seen
|
|
||||||
xml.description self.description
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Gera uma nova senha, e a envia por email.
|
def reset_login_key
|
||||||
def generate_password_reset_key!
|
self.login_key = Digest::SHA1.hexdigest(Time.now.to_s + password.to_s +
|
||||||
update_attribute(:password_reset_key, User.random_string(30))
|
rand(123_456_789).to_s).to_s
|
||||||
save!
|
end
|
||||||
Notifications.deliver_forgot_password(self.email, self.password_reset_key)
|
|
||||||
end
|
|
||||||
|
|
||||||
def reset_login_key
|
def reset_login_key!
|
||||||
self.login_key = Digest::SHA1.hexdigest(Time.now.to_s + password.to_s + rand(123456789).to_s).to_s
|
reset_login_key
|
||||||
end
|
save!
|
||||||
|
login_key
|
||||||
|
end
|
||||||
|
|
||||||
def reset_login_key!
|
def to_param
|
||||||
reset_login_key
|
login.match(/^[-_a-z0-9]*$/i).nil? ? id.to_s : login
|
||||||
save!
|
end
|
||||||
self.login_key
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_param
|
def courses_not_enrolled(period)
|
||||||
self.login.match(/^[-_a-z0-9]*$/i).nil? ? self.id.to_s : self.login
|
Course.all(conditions: ['period = ? and hidden = ? and id not in (?)',
|
||||||
end
|
period, false, courses])
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
def validate
|
|
||||||
if new_record?
|
|
||||||
errors.add_on_blank :password
|
|
||||||
errors.add_on_blank :password_confirmation
|
|
||||||
end
|
|
||||||
|
|
||||||
if !@password.blank?
|
def validate
|
||||||
errors.add(:password_confirmation) if @password_confirmation.blank? or @password != @password_confirmation
|
if new_record?
|
||||||
errors.add(:password, 'é muito curta') if !(5..40).include?(@password.length)
|
errors.add_on_blank :password
|
||||||
end
|
errors.add_on_blank :password_confirmation
|
||||||
end
|
end
|
||||||
|
|
||||||
def before_save
|
return unless @password.blank?
|
||||||
self.salt = User.random_string(10) if !self.salt?
|
errors.add(:password_confirmation) if @password_confirmation.blank? ||
|
||||||
self.secret = User.random_string(32) if !self.secret?
|
@password != @password_confirmation
|
||||||
self.hashed_password = User.encrypt(@password, self.salt) if !@password.blank?
|
errors.add(:password, 'é muito curta') unless @password.length >= 5
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.encrypt(pass, salt)
|
def before_save
|
||||||
Digest::SHA1.hexdigest(pass + salt)
|
self.salt = User.random_string(10) unless self.salt?
|
||||||
end
|
self.secret = User.random_string(32) unless self.secret?
|
||||||
|
self.hashed_password = User.encrypt(@password, salt) unless @password.blank?
|
||||||
|
end
|
||||||
|
|
||||||
def self.random_string(len)
|
def self.encrypt(pass, salt)
|
||||||
chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
|
Digest::SHA1.hexdigest(pass + salt)
|
||||||
newpass = ""
|
end
|
||||||
1.upto(len) { |i| newpass << chars[rand(chars.size-1)] }
|
|
||||||
return newpass
|
|
||||||
end
|
|
||||||
|
|
||||||
|
def self.random_string(len)
|
||||||
|
chars = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a
|
||||||
|
newpass = ''
|
||||||
|
1.upto(len) { |_i| newpass << chars[rand(chars.size - 1)] }
|
||||||
|
newpass
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -22,73 +22,68 @@
|
|||||||
require 'acts_as_versioned'
|
require 'acts_as_versioned'
|
||||||
require 'tempfile'
|
require 'tempfile'
|
||||||
|
|
||||||
|
|
||||||
class WikiPage < ActiveRecord::Base
|
class WikiPage < ActiveRecord::Base
|
||||||
|
|
||||||
attr_accessible :title, :front_page, :content, :description
|
attr_accessible :title, :front_page, :content, :description
|
||||||
attr_writer :type
|
|
||||||
|
|
||||||
# Plugins
|
# Plugins
|
||||||
acts_as_paranoid
|
acts_as_paranoid
|
||||||
acts_as_list :scope => 'course_id = #{course_id}'
|
acts_as_list scope: 'course_id = #{course_id}'
|
||||||
acts_as_versioned :if_changed => [:content, :description, :title]
|
acts_as_versioned if_changed: [:content, :description, :title]
|
||||||
self.non_versioned_columns << 'front_page'
|
non_versioned_columns << 'front_page'
|
||||||
self.non_versioned_columns << 'position'
|
non_versioned_columns << 'position'
|
||||||
self.non_versioned_columns << 'deleted_at'
|
non_versioned_columns << 'deleted_at'
|
||||||
self.non_versioned_columns << 'canonical_title'
|
non_versioned_columns << 'canonical_title'
|
||||||
|
|
||||||
# Associacoes
|
# Associacoes
|
||||||
belongs_to :course
|
belongs_to :course
|
||||||
belongs_to :user, :with_deleted => true
|
belongs_to :user, with_deleted: true
|
||||||
|
|
||||||
# Valicacao
|
# Valicacao
|
||||||
validates_presence_of :front_page
|
validates_presence_of :front_page
|
||||||
validates_presence_of :description
|
validates_presence_of :description
|
||||||
validates_presence_of :title
|
validates_presence_of :title
|
||||||
validates_presence_of :content
|
validates_presence_of :content
|
||||||
validates_uniqueness_of :title, :scope => :course_id
|
validates_uniqueness_of :title, scope: :course_id
|
||||||
validates_uniqueness_of :canonical_title, :scope => :course_id
|
validates_uniqueness_of :canonical_title, scope: :course_id
|
||||||
validates_format_of :title, :with => /^[^0-9]/
|
validates_format_of :title, with: /^[^0-9]/
|
||||||
|
|
||||||
before_validation :set_canonical_title
|
before_validation :set_canonical_title
|
||||||
before_save :set_position
|
before_save :set_position
|
||||||
|
|
||||||
# acts_as_paranoid_versioned
|
# acts_as_paranoid_versioned
|
||||||
self.versioned_class.class_eval do
|
versioned_class.class_eval do
|
||||||
def self.delete_all(conditions = nil)
|
def self.delete_all(_conditions = nil)
|
||||||
return
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_canonical_title
|
def set_canonical_title
|
||||||
self.canonical_title = self.title.pretty_url
|
canonical_title = title.pretty_url
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_position
|
def set_position
|
||||||
if !self.front_page
|
if !front_page
|
||||||
self.remove_from_list
|
remove_from_list
|
||||||
elsif self.position.nil?
|
elsif position.nil?
|
||||||
self.update_attribute(:position, (self.course.wiki_pages.maximum(:position)||0) + 1)
|
update_attribute(:position, (course.wiki_pages.maximum(:position) || 0) + 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate
|
def validate
|
||||||
begin
|
content.format_wiki
|
||||||
self.content.format_wiki
|
rescue
|
||||||
rescue
|
errors.add("content", "possui erro de sintaxe: " + $ERROR_INFO.to_s.html_escape)
|
||||||
errors.add("content", "possui erro de sintaxe: " + $!.to_s.html_escape)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_param
|
def to_param
|
||||||
self.canonical_title
|
canonical_title
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.find_front_page
|
def self.find_front_page
|
||||||
WikiPage.all(:conditions => ["front_page = ?", true])
|
WikiPage.all(conditions: ["front_page = ?", true])
|
||||||
end
|
end
|
||||||
|
|
||||||
def WikiPage.diff(from, to)
|
def self.diff(from, to)
|
||||||
# Cria um arquivo com o conteudo da versao antiga
|
# Cria um arquivo com o conteudo da versao antiga
|
||||||
original_content_file = Tempfile.new("old")
|
original_content_file = Tempfile.new("old")
|
||||||
original_content_file << from.content << "\n"
|
original_content_file << from.content << "\n"
|
||||||
@@ -100,12 +95,12 @@ class WikiPage < ActiveRecord::Base
|
|||||||
new_content_file.flush
|
new_content_file.flush
|
||||||
|
|
||||||
# Calcula as diferencas
|
# Calcula as diferencas
|
||||||
diff = `diff -u #{original_content_file.path()} #{new_content_file.path()}`
|
diff = `diff -u #{original_content_file.path} #{new_content_file.path}`
|
||||||
|
|
||||||
# Fecha os arquivos temporarios
|
# Fecha os arquivos temporarios
|
||||||
new_content_file.close!
|
new_content_file.close!
|
||||||
original_content_file.close!
|
original_content_file.close!
|
||||||
|
|
||||||
return diff
|
diff
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,29 +2,29 @@
|
|||||||
|
|
||||||
%dl
|
%dl
|
||||||
%dt
|
%dt
|
||||||
%label{:for => "course_full_name"} Nome completo
|
%label{:for => "course_full_name"}= Course.human_attribute_name(:full_name)
|
||||||
%dd= text_field 'course', 'full_name'
|
%dd= text_field 'course', 'full_name'
|
||||||
|
|
||||||
%dt
|
%dt
|
||||||
%label{:for => "course_short_name"} Nome abreviado
|
%label{:for => "course_short_name"}= Course.human_attribute_name(:short_name)
|
||||||
%dd= text_field 'course', 'short_name'
|
%dd= text_field 'course', 'short_name'
|
||||||
|
|
||||||
%dt
|
%dt
|
||||||
%label{:for => "course_code"} Código
|
%label{:for => "course_code"}= Course.human_attribute_name(:code)
|
||||||
%dd= text_field 'course', 'code'
|
%dd= text_field 'course', 'code'
|
||||||
|
|
||||||
%dt
|
%dt
|
||||||
%label{:for => "course_grade"} Semestre
|
%label{:for => "course_grade"}= Course.human_attribute_name(:grade)
|
||||||
%dd= text_field 'course', 'grade'
|
%dd= text_field 'course', 'grade'
|
||||||
|
|
||||||
%dt
|
%dt
|
||||||
%label{:for => "course_period"} Data
|
%label{:for => "course_period"}= Course.human_attribute_name(:period)
|
||||||
%dd= text_field 'course', 'period'
|
%dd= text_field 'course', 'period'
|
||||||
|
|
||||||
%dt
|
%dt
|
||||||
%label{:for => "course_hidden"} Ocultar
|
%label{:for => "course_hidden"}= Course.human_attribute_name(:hidden)
|
||||||
%dd= check_box 'course', 'hidden'
|
%dd= check_box 'course', 'hidden'
|
||||||
|
|
||||||
%dt
|
%dt
|
||||||
%label{:for => "course_description"} Descrição
|
%label{:for => "course_description"}= Course.human_attribute_name(:description)
|
||||||
%dd= preserve(text_area('course', 'description', :cols => 60, :rows => 10))
|
%dd= preserve(text_area('course', 'description', :cols => 60, :rows => 10))
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
%h4.title= App.title
|
%h4.title= App.title
|
||||||
%h1.title Editar disciplina
|
%h1.title= t(:edit_course)
|
||||||
|
|
||||||
%p
|
%p
|
||||||
= form_tag course_path(@course.id), :method => :put do
|
= form_tag course_path(@course.id), :method => :put do
|
||||||
= render :partial => 'form'
|
= render :partial => 'form'
|
||||||
= submit_tag 'Editar', :accesskey => 'e'
|
= submit_tag t(:edit), :accesskey => 'e'
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
.cmd
|
.cmd
|
||||||
= action_icon('add', 'Cadastrar nova disciplina', new_course_url, :accesskey => '+') if admin?
|
= action_icon('add', 'Cadastrar nova disciplina', new_course_url, accesskey: '+') if admin?
|
||||||
|
|
||||||
%h4.title= App.title
|
%h4.title= App.title
|
||||||
%h1.title= "Disciplinas #{@period}"
|
%h1.title= "Disciplinas #{@period}"
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
%ul
|
%ul
|
||||||
- if logged_in?
|
- if logged_in?
|
||||||
- if params[:period].nil?
|
- if params[:period].nil?
|
||||||
|
- @courses = @current_user.courses_not_enrolled(@period)
|
||||||
%h3 Disciplinas Matriculadas
|
%h3 Disciplinas Matriculadas
|
||||||
- if @current_user.courses.empty?
|
- if @current_user.courses.empty?
|
||||||
%li.no_itens Nenhuma disciplina matriculada
|
%li.no_itens Nenhuma disciplina matriculada
|
||||||
@@ -17,7 +18,7 @@
|
|||||||
= action_icon('subtract', 'Desmatricular-se', unenroll_course_url(course))
|
= action_icon('subtract', 'Desmatricular-se', unenroll_course_url(course))
|
||||||
= link_to h(course.full_name), course_url(course)
|
= link_to h(course.full_name), course_url(course)
|
||||||
|
|
||||||
-# cache(courses_path) do
|
-# cache(courses_path) do
|
||||||
- old_grade = 0
|
- old_grade = 0
|
||||||
- for course in @courses
|
- for course in @courses
|
||||||
- if course.grade != old_grade
|
- if course.grade != old_grade
|
||||||
@@ -32,5 +33,5 @@
|
|||||||
|
|
||||||
%h3
|
%h3
|
||||||
Outros Semestres
|
Outros Semestres
|
||||||
%li= link_to "2008.2", :period => '2008.2'
|
%li= link_to "2008.2", period: '2008.2'
|
||||||
%li= link_to "2008.1", :period => '2008.1'
|
%li= link_to "2008.1", period: '2008.1'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
%h4.title= App.title
|
%h4.title= App.title
|
||||||
%h1.title Adicionar disciplina
|
%h1.title= t(:new_course)
|
||||||
|
|
||||||
= form_tag courses_url, :method => :post do
|
= form_tag courses_url, :method => :post do
|
||||||
= render :partial => 'form'
|
= render :partial => 'form'
|
||||||
= submit_tag "Cadastrar", :accesskey => 'e'
|
= submit_tag t(:create), :accesskey => 'e'
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
.cmd
|
.cmd
|
||||||
- if admin?
|
- if admin?
|
||||||
= action_icon 'edit', 'Editar disciplina', edit_course_url, :accesskey => 'e'
|
= action_icon 'edit', t(:edit_course), edit_course_url, :accesskey => 'e'
|
||||||
=# action_icon 'trash', 'Excluir disciplina', course_url, :confirm => 'Tem certeza que deseja excluir?', :method => :delete
|
=# action_icon 'trash', 'Excluir disciplina', course_url, :confirm => 'Tem certeza que deseja excluir?', :method => :delete
|
||||||
|
|
||||||
-# cache(course_path(@course.id)) do
|
%h4.title= t(:course).capitalize
|
||||||
|
|
||||||
%h4.title Disciplina
|
|
||||||
%h1.title= h(@course.full_name)
|
%h1.title= h(@course.full_name)
|
||||||
|
|
||||||
%p= @course.description.format_wiki
|
%p= @course.description.format_wiki
|
||||||
@@ -31,32 +29,31 @@
|
|||||||
|
|
||||||
.box
|
.box
|
||||||
.cmd
|
.cmd
|
||||||
= action_icon 'add', 'Adicionar página wiki', new_course_wiki_instance_url(@course)
|
= action_icon 'add', t(:create_wiki_page), new_course_wiki_instance_url(@course)
|
||||||
|
|
||||||
%h3 Páginas Wiki
|
%h3= t(:wiki_pages)
|
||||||
%ul.wiki
|
%ul.wiki
|
||||||
- @course.wiki_pages.find_front_page.each do |wiki|
|
- @course.wiki_pages.find_front_page.each do |wiki|
|
||||||
%li{highlight(wiki.id)}
|
%li{highlight(wiki.id)}
|
||||||
.cmd{:style => 'margin-bottom: -27px; margin-top: -9px;'}
|
.cmd{:style => 'margin-bottom: -27px; margin-top: -9px;'}
|
||||||
=action_icon 'arrow2_n', 'Mover para cima', move_up_course_wiki_instance_url(@course.to_param, wiki.id) unless wiki.first?
|
=action_icon 'arrow2_n', t(:move_up), move_up_course_wiki_instance_url(@course.to_param, wiki.id) unless wiki.first?
|
||||||
=action_icon 'arrow2_s', 'Mover para baixo', move_down_course_wiki_instance_url(@course.to_param, wiki.id) unless wiki.last?
|
=action_icon 'arrow2_s', t(:move_down), move_down_course_wiki_instance_url(@course.to_param, wiki.id) unless wiki.last?
|
||||||
- if wiki.last?
|
- if wiki.last?
|
||||||
%span{:style => 'margin-right: 14px'}
|
%span{:style => 'margin-right: 14px'}
|
||||||
=link_to h(wiki.title), course_wiki_instance_url(@course.to_param, wiki.id)
|
=link_to h(wiki.title), course_wiki_instance_url(@course.to_param, wiki.id)
|
||||||
- if @course.wiki_pages.empty?
|
- if @course.wiki_pages.empty?
|
||||||
%li.no_itens Nenhuma página wiki
|
%li.no_itens= t(:no_wiki_pages)
|
||||||
- else
|
- else
|
||||||
%li.show_all= link_to "Ver todas as páginas wiki", course_wiki_url(@course)
|
%li.show_all= link_to t(:see_all_wiki_pages), course_wiki_url(@course)
|
||||||
|
|
||||||
.box
|
.box
|
||||||
.cmd= action_icon 'add', 'Adicionar anexo', new_course_attachment_url(@course)
|
.cmd= action_icon 'add', t(:create_attachment), new_course_attachment_url(@course)
|
||||||
|
|
||||||
%h3 Repositório de Arquivos
|
%h3= t(:repository)
|
||||||
.repositorio
|
.repositorio
|
||||||
= nested_attachments_to_html(attachments_to_nested_hash(@course.attachments.find_front_page))
|
= nested_attachments_to_html(attachments_to_nested_hash(@course.attachments.find_front_page))
|
||||||
- if @course.attachments.empty?
|
- if @course.attachments.empty?
|
||||||
%ul.wiki
|
%ul.wiki
|
||||||
%li.no_itens Nenhum arquivo
|
%li.no_itens= t(:no_attachments)
|
||||||
- else
|
- else
|
||||||
%li.show_all= link_to "Ver todos os arquivos", course_attachments_url(@course)
|
%li.show_all= link_to t(:see_all_attachments), course_attachments_url(@course)
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ module WikiUFC
|
|||||||
|
|
||||||
["#900", "#c00", "#444", "#888"],
|
["#900", "#c00", "#444", "#888"],
|
||||||
|
|
||||||
# Aqua
|
# Aqua
|
||||||
["#7b7", "#455", "#899", "#abb"],
|
["#7b7", "#455", "#899", "#abb"],
|
||||||
["#005B9A", "#455", "#899", "#abb"],
|
["#005B9A", "#455", "#899", "#abb"],
|
||||||
["#8D009A", "#455", "#899", "#abb"],
|
["#8D009A", "#455", "#899", "#abb"],
|
||||||
@@ -76,6 +76,8 @@ module WikiUFC
|
|||||||
# Templates
|
# Templates
|
||||||
config.initial_wiki_pages = ['Ementa', 'Notas de Aula']
|
config.initial_wiki_pages = ['Ementa', 'Notas de Aula']
|
||||||
config.initial_wiki_page_content = 'Página em branco.'
|
config.initial_wiki_page_content = 'Página em branco.'
|
||||||
|
|
||||||
|
config.i18n.default_locale = 'pt-BR'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -85,4 +87,3 @@ require "haml"
|
|||||||
require "haml/template"
|
require "haml/template"
|
||||||
Haml::Template.options[:escape_attrs] = false
|
Haml::Template.options[:escape_attrs] = false
|
||||||
Haml::Template.options[:escape_html] = false
|
Haml::Template.options[:escape_html] = false
|
||||||
|
|
||||||
|
|||||||
11
config/database.yml
Normal file
11
config/database.yml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
development:
|
||||||
|
adapter: sqlite3
|
||||||
|
database: db/wiki.sqlite3
|
||||||
|
|
||||||
|
test:
|
||||||
|
adapter: sqlite3
|
||||||
|
database: db/test.sqlite3
|
||||||
|
|
||||||
|
production:
|
||||||
|
adapter: sqlite3
|
||||||
|
database: db/wiki.sqlite3
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
#require 'brI18n'
|
|
||||||
|
|
||||||
WikiUFC::Application.configure do
|
WikiUFC::Application.configure do
|
||||||
# Settings specified here will take precedence over those in config/application.rb
|
# Settings specified here will take precedence over those in config/application.rb
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
#require 'brI18n'
|
|
||||||
|
|
||||||
WikiUFC::Application.configure do
|
WikiUFC::Application.configure do
|
||||||
# Settings specified here will take precedence over those in config/application.rb
|
# Settings specified here will take precedence over those in config/application.rb
|
||||||
|
|
||||||
@@ -67,4 +65,3 @@ WikiUFC::Application.configure do
|
|||||||
# with SQLite, MySQL, and PostgreSQL)
|
# with SQLite, MySQL, and PostgreSQL)
|
||||||
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -34,4 +34,6 @@ WikiUFC::Application.configure do
|
|||||||
|
|
||||||
# Print deprecation notices to the stderr
|
# Print deprecation notices to the stderr
|
||||||
config.active_support.deprecation = :stderr
|
config.active_support.deprecation = :stderr
|
||||||
|
|
||||||
|
config.i18n.default_locale = 'en'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
require 'ostruct'
|
|
||||||
::App = OpenStruct.new
|
|
||||||
|
|
||||||
# Define os campos essenciais
|
|
||||||
required_fields = %w(
|
|
||||||
title
|
|
||||||
language
|
|
||||||
max_upload_file_size
|
|
||||||
default_color
|
|
||||||
)
|
|
||||||
|
|
||||||
# Carrega as configuracoes personalizadas
|
|
||||||
require "#{RAILS_ROOT}/config/application.rb"
|
|
||||||
|
|
||||||
# Verifica se todas os campos essenciais foram instanciados
|
|
||||||
required_fields.each do |field|
|
|
||||||
raise "Required configuration not found: App.#{field}" unless App.respond_to?(field)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Internacionalizacao
|
|
||||||
#Gibberish.current_language = App.language if RAILS_ENV != 'test'
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
#TzTime.zone = TZInfo::Timezone.new("America/Fortaleza")
|
|
||||||
|
|
||||||
class Time
|
|
||||||
alias :strftime_nolocale :strftime
|
|
||||||
|
|
||||||
def strftime(format)
|
|
||||||
format = format.dup
|
|
||||||
format.gsub!(/%a/, Date::ABBR_DAYNAMES[self.wday])
|
|
||||||
format.gsub!(/%A/, Date::DAYNAMES[self.wday])
|
|
||||||
format.gsub!(/%b/, Date::ABBR_MONTHNAMES[self.mon])
|
|
||||||
format.gsub!(/%B/, Date::MONTHNAMES[self.mon])
|
|
||||||
self.strftime_nolocale(format)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
|
|
||||||
:default => '%d/%m/%Y %H:%M',
|
|
||||||
:date_time12 => "%d/%m/%Y %I:%M%p",
|
|
||||||
:date_time24 => "%d/%m/%Y %H:%M"
|
|
||||||
)
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
# Be sure to restart your server when you modify this file.
|
|
||||||
|
|
||||||
# These settings change the behavior of Rails 2 apps and will be defaults
|
|
||||||
# for Rails 3. You can remove this initializer when Rails 3 is released.
|
|
||||||
|
|
||||||
if defined?(ActiveRecord)
|
|
||||||
# Include Active Record class name as root for JSON serialized output.
|
|
||||||
ActiveRecord::Base.include_root_in_json = true
|
|
||||||
|
|
||||||
# Store the full class name (including module namespace) in STI type column.
|
|
||||||
ActiveRecord::Base.store_full_sti_class = true
|
|
||||||
end
|
|
||||||
|
|
||||||
# Use ISO 8601 format for JSON serialized times and dates.
|
|
||||||
ActiveSupport.use_standard_json_time_format = true
|
|
||||||
|
|
||||||
# Don't escape HTML entities in JSON, leave that for the #json_escape helper.
|
|
||||||
# if you're including raw json in an HTML page.
|
|
||||||
ActiveSupport.escape_html_entities_in_json = false
|
|
||||||
@@ -4,6 +4,8 @@ pt-BR:
|
|||||||
course_created: Disciplina cadastrada
|
course_created: Disciplina cadastrada
|
||||||
course_updated: Disciplina editada
|
course_updated: Disciplina editada
|
||||||
course_removed: Disciplina excluída
|
course_removed: Disciplina excluída
|
||||||
|
edit_course: Editar disciplina
|
||||||
|
new_course: Cadastrar disciplina
|
||||||
|
|
||||||
event: evento
|
event: evento
|
||||||
events: eventos
|
events: eventos
|
||||||
@@ -29,22 +31,32 @@ pt-BR:
|
|||||||
attachment_updated: Arquivo editado
|
attachment_updated: Arquivo editado
|
||||||
attachment_removed: Arquivo excluído
|
attachment_removed: Arquivo excluído
|
||||||
attachment_restored: Arquivo restaurado
|
attachment_restored: Arquivo restaurado
|
||||||
|
create_attachment: Adicionar arquivo
|
||||||
|
see_all_attachments: Ver todos os arquivos
|
||||||
|
no_attachments: Nenhum arquivo
|
||||||
|
repository: Repositório de Arquivos
|
||||||
|
|
||||||
wiki_page: Página wiki
|
wiki_page: Página wiki
|
||||||
|
wiki_pages: Páginas wiki
|
||||||
wiki_page_created: Página wiki criada
|
wiki_page_created: Página wiki criada
|
||||||
wiki_page_removed: Página wiki removida
|
wiki_page_removed: Página wiki removida
|
||||||
wiki_page_updated: Página wiki atualizada
|
wiki_page_updated: Página wiki atualizada
|
||||||
wiki_page_restored: Página wiki restaurada
|
wiki_page_restored: Página wiki restaurada
|
||||||
|
create_wiki_page: Adicionar página wiki
|
||||||
|
see_all_wiki_pages: Ver todas as páginas wiki
|
||||||
|
no_wiki_pages: Nenhuma página wiki
|
||||||
|
|
||||||
recent_changes: Mudanças recentes
|
recent_changes: Mudanças recentes
|
||||||
log_about: Mudanças recentes em {disciplina}
|
log_about: Mudanças recentes em {disciplina}
|
||||||
|
|
||||||
undo: Desfazer
|
|
||||||
login_failed: Não foi possível fazer login
|
login_failed: Não foi possível fazer login
|
||||||
login_required: É necessário fazer login para acessar esta área do site
|
login_required: É necessário fazer login para acessar esta área do site
|
||||||
login_success: Olá, {u}!
|
login_success: Olá, {u}!
|
||||||
logout_success: Você fez logout
|
logout_success: Você fez logout
|
||||||
|
|
||||||
|
move_up: Mover para cima
|
||||||
|
move_down: Mover para baixo
|
||||||
|
|
||||||
navigation: navegação
|
navigation: navegação
|
||||||
forums: fórums
|
forums: fórums
|
||||||
|
|
||||||
@@ -55,6 +67,9 @@ pt-BR:
|
|||||||
is_too_large: é grande demais
|
is_too_large: é grande demais
|
||||||
is_needed: é requerido
|
is_needed: é requerido
|
||||||
|
|
||||||
|
undo: Desfazer
|
||||||
|
create: Cadastrar
|
||||||
|
|
||||||
body: conteúdo
|
body: conteúdo
|
||||||
code: código
|
code: código
|
||||||
content: conteúdo
|
content: conteúdo
|
||||||
@@ -70,22 +85,21 @@ pt-BR:
|
|||||||
short_name: nome abreviado
|
short_name: nome abreviado
|
||||||
time: horário
|
time: horário
|
||||||
title: título
|
title: título
|
||||||
|
edit: Editar
|
||||||
|
|
||||||
logged_in_as: Identificado como %{u}
|
logged_in_as: Bem vindo %{u}
|
||||||
member_since: Membro desde %{c}
|
member_since: Membro desde %{c}
|
||||||
last_seen: Última visita há %{c}
|
last_seen: Última visita há %{c}
|
||||||
welcome_back: Bem vindo %{u}
|
welcome_back: Bem vindo %{u}
|
||||||
dashboard: Dashboard
|
dashboard: Dashboard
|
||||||
|
|
||||||
number:
|
activerecord:
|
||||||
human:
|
attributes:
|
||||||
storage_units:
|
course:
|
||||||
format: "%n %u"
|
short_name: Nome abreviado
|
||||||
units:
|
full_name: Nome completo
|
||||||
byte:
|
description: Descrição
|
||||||
one: "Byte"
|
code: Código
|
||||||
other: "Bytes"
|
grade: Semestre
|
||||||
kb: "KB"
|
period: Data
|
||||||
mb: "MB"
|
hidden: Oculto
|
||||||
gb: "GB"
|
|
||||||
tb: "TB"
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ require File.dirname(__FILE__) + '/../test_helper.rb'
|
|||||||
require 'courses_controller'
|
require 'courses_controller'
|
||||||
|
|
||||||
# Re-raise errors caught by the controller.
|
# Re-raise errors caught by the controller.
|
||||||
#class CoursesController; def rescue_action(e) raise e end; end
|
# class CoursesController; def rescue_action(e) raise e end; end
|
||||||
|
|
||||||
class CoursesControllerTest < ActionController::TestCase
|
class CoursesControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
@@ -34,13 +34,13 @@ class CoursesControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "An anonymous user" do
|
context "An anonymous user" do
|
||||||
|
|
||||||
should_have_access_denied_on_post_to(:new, {})
|
should_request_login_on_post_to(:new, {})
|
||||||
should_have_access_denied_on_post_to(:create, {})
|
should_request_login_on_post_to(:create, {})
|
||||||
should_have_access_denied_on_post_to(:edit, {:id => 1})
|
should_request_login_on_post_to(:edit, id: 1)
|
||||||
should_have_access_denied_on_post_to(:update, {:id => 1})
|
should_request_login_on_post_to(:update, id: 1)
|
||||||
should_have_access_denied_on_post_to(:destroy, {:id => 1})
|
should_request_login_on_post_to(:destroy, id: 1)
|
||||||
should_request_login_on_post_to(:enroll, {:id => 1})
|
should_request_login_on_post_to(:enroll, id: 1)
|
||||||
should_request_login_on_post_to(:unenroll, {:id => 1})
|
should_request_login_on_post_to(:unenroll, id: 1)
|
||||||
|
|
||||||
context "on get to :index" do
|
context "on get to :index" do
|
||||||
setup { get :index }
|
setup { get :index }
|
||||||
@@ -54,13 +54,13 @@ class CoursesControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "display the selected period" do
|
should "display the selected period" do
|
||||||
get :index, :period => "1970.1"
|
get :index, period: "1970.1"
|
||||||
assert_select 'h1', "Disciplinas 1970.1"
|
assert_select 'h1', "Disciplinas 1970.1"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "on get to :show" do
|
context "on get to :show" do
|
||||||
setup { get :show, :id => @course.id }
|
setup { get :show, id: @course.id }
|
||||||
|
|
||||||
should respond_with :success
|
should respond_with :success
|
||||||
should render_template 'show'
|
should render_template 'show'
|
||||||
@@ -83,8 +83,8 @@ class CoursesControllerTest < ActionController::TestCase
|
|||||||
#context "A user" do
|
#context "A user" do
|
||||||
# setup { login_as :bob }
|
# setup { login_as :bob }
|
||||||
# should_be_restful do |resource|
|
# should_be_restful do |resource|
|
||||||
# resource.create.params = { :short_name => 'test', :full_name => 'test', :description => 'test' }
|
# resource.create.params = { short_name: 'test', full_name: 'test', description: 'test' }
|
||||||
# resource.update.params = { :short_name => 'test', :full_name => 'test', :description => 'test' }
|
# resource.update.params = { short_name: 'test', full_name: 'test', description: 'test' }
|
||||||
# end
|
# end
|
||||||
#end
|
#end
|
||||||
|
|
||||||
@@ -92,8 +92,8 @@ class CoursesControllerTest < ActionController::TestCase
|
|||||||
#context "A stranger" do
|
#context "A stranger" do
|
||||||
# setup { logout }
|
# setup { logout }
|
||||||
# should_be_restful do |resource|
|
# should_be_restful do |resource|
|
||||||
# resource.create.params = { :short_name => 'test', :full_name => 'test', :description => 'test' }
|
# resource.create.params = { short_name: 'test', full_name: 'test', description: 'test' }
|
||||||
# resource.update.params = { :short_name => 'test', :full_name => 'test', :description => 'test' }
|
# resource.update.params = { short_name: 'test', full_name: 'test', description: 'test' }
|
||||||
# resource.denied.actions = [ :new, :edit, :create, :update, :destroy ]
|
# resource.denied.actions = [ :new, :edit, :create, :update, :destroy ]
|
||||||
# resource.denied.redirect = "'/login'"
|
# resource.denied.redirect = "'/login'"
|
||||||
# resource.denied.flash = /must be logged in/i
|
# resource.denied.flash = /must be logged in/i
|
||||||
|
|||||||
Reference in New Issue
Block a user