Class: Bible270::ReadersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Bible270::ReadersController
- Defined in:
- app/controllers/bible270/readers_controller.rb
Instance Method Summary collapse
- #index ⇒ Object
-
#progress ⇒ Object
The reader's own progress.
- #show ⇒ Object
Instance Method Details
#index ⇒ Object
5 6 7 8 9 10 11 |
# File 'app/controllers/bible270/readers_controller.rb', line 5 def index # Community is a directory of fellow readers, not a leaderboard. Keep the # order predictable without implying that progress determines standing. @readers = Reader.all.to_a.sort_by(&:sort_name) @show_admin_progress = Bible270.config.admin?(current_reader) @days_completed = Reader.completed_days_by_id if @show_admin_progress end |
#progress ⇒ Object
The reader's own progress. Deliberately open to visitors: the panel shows an invitation to sign in rather than an error, and every value it needs comes from the reader it is given.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/bible270/readers_controller.rb', line 16 def progress @reader = current_reader # Defaults keep the open visitor page simple and make every view input explicit. @recent_comments = @reader ? @reader.comments.recent.limit(5) : Comment.none @partial_day_tasks = [] @remaining_partial_days = 0 return unless @reader partial_days = @reader.partial_days @partial_day_tasks = partial_days.first(5).map do |day| { day: day, remaining: @reader.remaining_parts_for(day) } end @remaining_partial_days = [partial_days.size - @partial_day_tasks.size, 0].max end |
#show ⇒ Object
31 32 33 34 35 36 37 |
# File 'app/controllers/bible270/readers_controller.rb', line 31 def show @reader = Reader.find_by(id: params[:id]) redirect_to(community_path, alert: 'Reader not found.') and return unless @reader @days_completed = @reader.days_completed @recent_comments = @reader.comments.recent.limit(20) end |