first commit, largely copied volunteers

This commit is contained in:
2023-10-25 22:14:53 +03:00
commit 608b4f6ddf
222 changed files with 5121 additions and 0 deletions

View File

@ -0,0 +1,3 @@
class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
end

View File

35
app/models/member.rb Normal file
View File

@ -0,0 +1,35 @@
class Member < ApplicationRecord
after_create :skip_conf!
def self.public_scope
where.not(confirmed_at: nil).where.not(picture: nil)
end
def self.visible_scope
where.not(confirmed_at: nil)
end
# Include default devise modules. Others available are:
# , :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,:confirmable,
:recoverable, :rememberable, :validatable, :async
def skip_conf!
self.confirm if Rails.env.development?
end
mount_uploader :picture, PictureUploader
has_many :stories
has_many :stories
has_many :pictures
validates :bio, length: { maximum: 1000 }
validates :name , length: { minimum: 3 }
def admin
self.email == "torsten@villataika.fi"
end
def admin?
self.email == "torsten@villataika.fi"
end
end

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

@ -0,0 +1,10 @@
class Picture < ApplicationRecord
belongs_to :member
mount_uploader :picture, PictureUploader
validates :text, length: { maximum: 80 }
validates :happened, presence: true
validates :picture, presence: true
end

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

@ -0,0 +1,13 @@
class Story < ApplicationRecord
belongs_to :member
mount_uploader :picture, PictureUploader
validates :text, length: { minimum: 5 , maximum: 1000 }
validates :header , length: { minimum: 5 , maximum: 400}
validates :picture, presence: true
def name
header
end
end