-
Notifications
You must be signed in to change notification settings - Fork 0
Controllers #7
Controllers #7
Conversation
app/controllers/duties_controller.rb
Outdated
|
|
||
| redirect_to action: 'index' if @timeslot_id.update(@user_id) | ||
| end | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add private here
app/controllers/duties_controller.rb
Outdated
| redirect_to action: 'index' if @duty_id.update(@user_id) | ||
| end | ||
|
|
||
| def setdefault |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set_default
app/controllers/duties_controller.rb
Outdated
| def index | ||
| date = params[:date] | ||
| starting_date = date - (date.cwdays - 1) | ||
| @duties = Array.new(7) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Array.new(starting_date..(starting_date + 7)) does this work?
app/controllers/duties_controller.rb
Outdated
| end | ||
|
|
||
| def process_grab | ||
| @user_id = User.find(user_id_params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@user not @user_id
app/controllers/duties_controller.rb
Outdated
| redirect_to action: 'index' if @duty_id.update(:user_id, nil) | ||
| end | ||
|
|
||
| def edit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're going to do a mass update, just like in the old duty website. Maybe check the current admin panel?
app/controllers/duties_controller.rb
Outdated
| @user_id = User.find(user_id_params) | ||
| @duty_id = Duty.find(duty_id_params) | ||
|
|
||
| # user_id of duty_id should and must be null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get what's this?
app/controllers/duties_controller.rb
Outdated
| redirect_to action: 'index' if @timeslot_id.update(@user_id) | ||
| end | ||
|
|
||
| def user_id_params |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user_params
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, actually what is this for?
… update function in the action 'update'
|
Progress? |
donjar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gogogo
| expect(flash[:notice]).to eq 'Successfully grabbed duty!' | ||
| end | ||
|
|
||
| it 'shows error if user is not found' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:o what
| week_offset = params[:week_offset] | ||
| day_offset = (Time.zone.now.wday - 1) % 7 | ||
| start_date = Time.zone.now - day_offset.days + week_offset.weeks | ||
| @duties = Duty.where("date >= #{start_date} && " \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be abstracted out to be a model function, something like Duty.week_of(Time.zone.now - 7.days)?
No description provided.