GitHub Account angelegt

This commit is contained in:
Andreas Stephanides
2013-02-12 02:05:12 +01:00
commit 3d11400d5e
216 changed files with 5031 additions and 0 deletions

0
app/models/.gitkeep Normal file
View File

31
app/models/ability.rb Normal file
View File

@@ -0,0 +1,31 @@
class Ability
include CanCan::Ability
def initialize(user)
# Define abilities for the passed in user here. For example:
#
user ||= User.new # guest user (not logged in)
# if user.admin?
# can :manage, :all
# else
# can :read, :all
# end
can :read, Modulgruppe
if user.has_role? "newsadmin"
can :manage, Modulgruppe
end
# The first argument to `can` is the action you are giving the user permission to do.
# If you pass :manage it will apply to every action. Other common actions here are
# :read, :create, :update and :destroy.
#
# The second argument is the resource the user can perform the action on. If you pass
# :all it will apply to every resource. Otherwise pass a Ruby class of the resource.
#
# The third argument is an optional hash of conditions to further filter the objects.
# For example, here the user can only update published articles.
#
# can :update, Article, :published => true
#
# See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities
end
end

7
app/models/lva.rb Normal file
View File

@@ -0,0 +1,7 @@
class Lva < ActiveRecord::Base
has_paper_trail # Versionsver
attr_accessible :desc, :ects, :lvanr, :name, :stunden, :modul_ids
has_and_belongs_to_many :modul
has_and_belongs_to_many :semester
translates :desc, :fallbacks_for_empty_translations => true
end

9
app/models/modul.rb Normal file
View File

@@ -0,0 +1,9 @@
class Modul < ActiveRecord::Base
attr_accessible :desc,:name, :depend, :studium_id, :modulgruppe_ids
has_and_belongs_to_many :lvas
has_and_belongs_to_many :modulgruppen
translates :desc,:depend, :versioning =>true, :fallbacks_for_empty_translations => true
end

11
app/models/modulgruppe.rb Normal file
View File

@@ -0,0 +1,11 @@
class Modulgruppe < ActiveRecord::Base
attr_accessible :name, :phase, :typ,:desc, :studium_id
belongs_to :studium, :foreign_key => "studium_id"
has_and_belongs_to_many :moduls
resourcify
validates :studium, :presence=>true
validates :name, :presence=>true,:uniqueness =>{:scope => :studium, :message => "Nur einmal je Studium erlaubt"}
validates :phase, :numericality => { :only_integer => true },:inclusion => {:in => [1, 2, 3, 4], :message => "%{value} is not valid, choose phase 1 to 4"}, :presence=>true
validates :typ, :inclusion => {:in => ["Pflicht","Vertiefungspflicht","Wahl"] }
translates :name,:desc, :versioning =>true,:fallbacks_for_empty_translations => true
end

5
app/models/neuigkeit.rb Normal file
View File

@@ -0,0 +1,5 @@
class Neuigkeit < ActiveRecord::Base
attr_accessible :datum, :text, :title
belongs_to :author, :class_name =>'User'
belongs_to :rubrik
end

6
app/models/role.rb Normal file
View File

@@ -0,0 +1,6 @@
class Role < ActiveRecord::Base
has_and_belongs_to_many :users, :join_table => :users_roles
belongs_to :resource, :polymorphic => true
scopify
end

10
app/models/rubrik.rb Normal file
View File

@@ -0,0 +1,10 @@
class Rubrik < ActiveRecord::Base
attr_accessible :desc, :name, :prio
has_many :neuigkeiten
def moderator
end
def moderator=(id)
User.find(id).add_role(:newsmoderator, self)
end
end

4
app/models/semester.rb Normal file
View File

@@ -0,0 +1,4 @@
class Semester < ActiveRecord::Base
has_and_belongs_to_many :lvas
attr_accessible :name, :nummer, :ss, :ws
end

6
app/models/studium.rb Normal file
View File

@@ -0,0 +1,6 @@
class Studium < ActiveRecord::Base
attr_accessible :desc, :name, :typ, :zahl
has_many :modulgruppen, inverse_of: :studium, :class_name => "Modulgruppe"
validates :zahl, :uniqueness => true
translates :desc,:shortdesc, :versioning =>true,:fallbacks_for_empty_translations => true
end

13
app/models/user.rb Normal file
View File

@@ -0,0 +1,13 @@
class User < ActiveRecord::Base
rolify
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,:confirmable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
# attr_accessible :title, :body
end