Class: Course::AnnouncementsController

Inherits:
ComponentController show all
Defined in:
app/controllers/course/announcements_controller.rb

Instance Method Summary collapse

Methods included from ApplicationSignInCallbacksConcern

#sign_in

Methods included from ApplicationPaginationConcern

#page_param

Methods included from ApplicationAnnouncementsConcern

#global_announcements, #unread_global_announcements

Methods included from ApplicationInstanceUserConcern

#current_instance_user

Methods included from ApplicationUserTimeZoneConcern

#set_time_zone

Methods included from ApplicationUserConcern

#handle_access_denied, #publicly_accessible?

Methods included from ApplicationComponentsConcern

#handle_component_not_found

Instance Method Details

#createObject

:nodoc:


18
19
20
21
22
23
24
25
# File 'app/controllers/course/announcements_controller.rb', line 18

def create #:nodoc:
  if @announcement.save
    redirect_to course_announcements_path(current_course),
                success: t('.success', title: @announcement.title)
  else
    render 'new'
  end
end

#destroyObject

:nodoc:


39
40
41
42
43
44
45
46
47
# File 'app/controllers/course/announcements_controller.rb', line 39

def destroy #:nodoc:
  if @announcement.destroy
    redirect_to course_announcements_path(current_course),
                success: t('.success', title: @announcement.title)
  else
    redirect_to course_announcements_path(current_course),
                danger: t('.failure', error: @announcement.errors.full_messages.to_sentence)
  end
end

#editObject

:nodoc:


27
28
# File 'app/controllers/course/announcements_controller.rb', line 27

def edit #:nodoc:
end

#indexObject

:nodoc:


7
8
9
10
# File 'app/controllers/course/announcements_controller.rb', line 7

def index #:nodoc:
  @announcements = @announcements.includes(:creator).sorted_by_sticky.sorted_by_date
  @announcements = @announcements.page(page_param).with_read_marks_for(current_user)
end

#newObject

:nodoc:


15
16
# File 'app/controllers/course/announcements_controller.rb', line 15

def new #:nodoc:
end

#showObject

:nodoc:


12
13
# File 'app/controllers/course/announcements_controller.rb', line 12

def show #:nodoc:
end

#updateObject

:nodoc:


30
31
32
33
34
35
36
37
# File 'app/controllers/course/announcements_controller.rb', line 30

def update #:nodoc:
  if @announcement.update_attributes(announcement_params)
    redirect_to course_announcements_path(current_course),
                success: t('.success', title: @announcement.title)
  else
    render 'edit'
  end
end