Created
October 17, 2011 18:51
-
-
Save lcowell/1293439 to your computer and use it in GitHub Desktop.
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
# Sessions are the anchor for most activity on the site. Almost every resource will be | |
#related to a session. Sessions have 3 states: open, closed and published. | |
session = IwiSession.find(params[:id]) | |
# New Sessions | |
# A session is by default an open session. When making a new session, the participants from | |
# the previous session are copied forward. The most recent previous session will exclude one-time | |
# sessions. | |
# Open Sessions | |
# You can only have one open session at a time. You can still make one time and historic sessions. | |
# Make the session an historic session. This changes the object, but does not persist it | |
session.historic! | |
# make the session a one time session. One time sessions are not considered when making a | |
# new session. participants. | |
one_time! | |
# Closed Sessions | |
# You can only close a session if a winner has been selected. You cannot remove the winner | |
# from a closed session. | |
# Published Sessions | |
# Can can only publish a session once it has been closed. | |
# get the title | |
session.title | |
# get the brief | |
session.brief | |
# get the deadline | |
session.deadline | |
# get the session winner, returns nil if none present | |
session.winner | |
# Session Presentations | |
# When a session is closed, it is possible to select any group's entry to be included in the presentation. | |
# These entries (GroupInstance) are associated with the session using a join table called | |
# presentation_rosters. This table joins the 2 models and records including the position, which allows us | |
#to #reorder the group instances and set the order for the presentation. | |
# entry_ids= take a string of comma delimited group_instance_ids. This method is used for setting the | |
# group instances that are to be included in the session presentation. | |
session.entry_ids=("1,2,3") | |
# get the session highlights file | |
session.hightlight_presentation | |
# get the url of the highlights file, returns default URL if none present | |
session.hightlight_presentation_url | |
# Group Instances | |
# This should be thought of as (and possibly renamed to) 'entry'. Each time a group participates in a | |
# session it is joined to the session through a group_instance. This means a group can remain unlisted if | |
# they are not participating in the session. | |
# Group instances also link to an asset, which is where we store the group's submission. | |
# Group | |
# The group model stores the group's name and logo | |
# Assets | |
# Assets are associated using a polymorphic association. This means that we can associated the asset | |
# model with various resources and reuse the asset code. Assets store a powerpoint file as well as | |
# the associated thumbnails. Assets are used to store a group's entry for a session as well as | |
# the highlight presentation, which is uploaded then the presentation has been closed. | |
# Thumbnails | |
# Thumbnails belong to an asset and are ordered by position. | |
# Users | |
# Users belong to a group through a group_instance. However because a user may or may not be participating | |
# in each session we join join the user to a group instance through the group assignment model. The | |
# association ends up looking like this. | |
# user -> group_assignments <-> group_instance <-> group | |
session.group_instances.each do |group_instance| | |
# you'll do most of your work through group_instance | |
# iterate over each user on a given team | |
group_instance.users.each do |user| | |
user.first_name | |
... | |
end | |
# get the group's name | |
group_instance.group_name | |
# get the group's logo | |
group_instance.group_logo_url | |
# URL for a group's submission to the session, returns default URL if none present | |
group_instance.asset_url | |
# to access each thumbnail for a presentation. | |
group_instance.thumbnail_urls | |
# You can also pass a style which is sent to each of the thumbnail. The following should be the same: | |
group_instance.thumbnail_urls(:small) == group_instance.thumbnails.each {|t| t.url(:small) } | |
# the winner for a session is a group_instance, so in the loop you detect the winner as follows: | |
session.winner?(group_instance) | |
end | |
# get the name of the iwi presentation based on the session's entries | |
session.presentation_name | |
# when setting up a presentation, here's how we access the collection of group_instances, each of which has an attached asset, to included in the presentation. | |
session.selected_entries.each do |group_instance| | |
group_instance.asset_url | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment