-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
67 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -222,6 +222,3 @@ DEPENDENCIES | |
whenever (~> 0.9.4) | ||
will_paginate (~> 3.0.6) | ||
will_paginate-bootstrap | ||
|
||
BUNDLED WITH | ||
1.10.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,17 @@ | ||
class UsersSubject < ActiveRecord::Base | ||
acts_as_paranoid | ||
STATUS = { | ||
new: 0, | ||
started: 1, | ||
finished: 2 | ||
} | ||
|
||
enum status: [:created, :started, :finished] | ||
include PublicActivity::Model | ||
tracked owner: ->(controller, model) {controller && controller.current_user} | ||
|
||
belongs_to :user | ||
belongs_to :courses_subject | ||
belongs_to :subject | ||
scope :finished, ->{where status: STATUS[:finished]} | ||
|
||
class << self | ||
def find_by_user user_id | ||
UsersSubject.find_by user_id: user_id, finished: true | ||
end | ||
end | ||
|
||
def new? | ||
status == STATUS[:new] | ||
end | ||
|
||
def started? | ||
status == STATUS[:started] | ||
end | ||
|
||
def finished? | ||
status == STATUS[:finished] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
class AddSupervisorToUsers < ActiveRecord::Migration | ||
def change | ||
add_column :users, :supervisor, :boolean, default: false | ||
add_column :users, :role, :boolean, default: false | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,12 @@ | |
last_name: "test", | ||
email: "[email protected]", | ||
password: "password", | ||
supervisor: true | ||
role: :supervisor | ||
supervisor2 = User.create! first_name: "test1", | ||
last_name: "test1", | ||
email: "[email protected]", | ||
password: "password", | ||
supervisor: true | ||
role: :supervisor | ||
## trainees | ||
99.times do |n| | ||
first_name = Faker::Name.first_name | ||
|
@@ -38,16 +38,10 @@ | |
description: Faker::Lorem.paragraph, | ||
start_date: Faker::Date.backward, | ||
end_date: Faker::Date.forward, | ||
status: 0 | ||
course.users = [supervisor1] | ||
status: :created | ||
|
||
5.times do |uc| | ||
course.user_ids = course.user_ids << trainees.sample.id | ||
end | ||
|
||
3.times do |cs| | ||
course.subject_ids = course.subject_ids << subjects.sample.id | ||
end | ||
course.subjects = subjects.sample 3 | ||
course.users = [supervisor1] + trainees.sample(5) | ||
course.save! | ||
end | ||
|
||
|