Skip to content
This repository has been archived by the owner on Apr 14, 2018. It is now read-only.

Commit

Permalink
Merge branch 'v0.2.0' into 'master'
Browse files Browse the repository at this point in the history
This comprises the version 0.2.0 release.

Conflicts:
	app/controllers/docket_controller.rb
	app/views/docket/index.html.erb
	app/views/layouts/application.html.erb
	config/initializers/docket.rb

Conflicts appear to have been resolved.

Signed-off-by: Kristofer Rye <[email protected]>
  • Loading branch information
rye committed Jan 22, 2014
2 parents b4b9d23 + bb69d35 commit 9de36ac
Show file tree
Hide file tree
Showing 35 changed files with 399 additions and 124 deletions.
3 changes: 2 additions & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
//= require jquery_ujs
//= require jquery.turbolinks
//= require bootstrap
//= require docket-toggle
//= require typeahead

var ready;
Expand All @@ -38,7 +39,7 @@ $(document).ready(ready);
$(document).ready(function () {

/*
* Clamped-width.
* Clamped-width.
* Usage:
* <div data-clampedwidth=".myParent">This long content will force clamped width</div>
*
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/configuration.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
40 changes: 40 additions & 0 deletions app/assets/javascripts/docket-toggle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
function docket_collapse_toggle(day_tag)
{
var panel = document.getElementById("docket-collapsing-day-panel-" + day_tag);
var icon = panel.getElementsByClassName("docket-collapsing-indicator-image")[0];
var body = panel.getElementsByClassName("docket-collapsing-div-data")[0];

var collapsed = panel.getAttribute("docket-is-collapsed") == "true" ? true : false;
var icon_future_class_name = collapsed ? "glyphicon-chevron-up" : "glyphicon-chevron-down";

var icon_classes = icon.className.split(" ");
var new_icon_classes = [];

icon_classes.map(function(cls)
{
var match = cls.match(/glyphicon-chevron-(up|down)/g);

/* Stop errors */
if(match == null || match == undefined) {
new_icon_classes.push(cls);

return;
}

if(match.length > 0) {
new_icon_classes.push(icon_future_class_name);

return;
}
});

icon.className = new_icon_classes.join(" ");

if(collapsed) {
panel.setAttribute("docket-is-collapsed", "false");
body.style.display = "inherit";
} else {
panel.setAttribute("docket-is-collapsed", "true");
body.style.display = "none";
}
}
30 changes: 26 additions & 4 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ body {
padding-top: 70px;
}

.page-header {
margin-top: 0px;
}

.twitter-typeahead {
.tt-query, .tt-hint {
margin-bottom: 0;
Expand All @@ -59,11 +63,11 @@ body {
.tt-suggestion {
display: block;
padding: 3px 20px;

p {
margin: 0;
}

&.tt-is-under-cursor {
color: #fff;
background-color: #0081c2;
Expand All @@ -85,15 +89,15 @@ body {
border: 1px solid transparent;
border-radius:4px;
}

.hint-small {
height: 30px;
padding: 5px 10px;
font-size: 12px;
border-radius: 3px;
line-height: 1.5;
}

.hint-large {
height: 45px;
padding: 10px 16px;
Expand All @@ -116,3 +120,21 @@ body {
.link-no-underline:hover {
text-decoration: none;
}

.hr-less-padding {
margin-top: 8px;
margin-bottom: 8px;
}

.navbar-inverse {
background-color: #303030;
border-color: #101010;

a, p, li {
color: #a0a0a0;
}

a :hover {
color: #f0f0f0;
}
}
3 changes: 3 additions & 0 deletions app/assets/stylesheets/configuration.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the configuration controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
10 changes: 10 additions & 0 deletions app/controllers/configuration_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class ConfigurationController < ApplicationController
def show
end

def edit
end

def update
end
end
43 changes: 30 additions & 13 deletions app/controllers/docket_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,52 @@ class DocketController < ApplicationController
def index
redirect_to log_in_path, notice: "Please log in to use Docket." unless current_user

@today_and_tomorrow_exams = []
@current_day = Date.today
@days_of_this_week = []

difference_between_today_and_start_of_week = @current_day.wday
start_of_week = @current_day - difference_between_today_and_start_of_week.days

(0..6).each do |wnum|
@days_of_this_week << start_of_week + wnum.days
end

start_of_other_range = @days_of_this_week.last

@this_week_exams = []
@other_exams = []

current_user.exams.each do |e|
case
when ((e.date == Date.today) or (e.date == Date.today + 1.day))
@today_and_tomorrow_exams << e
when e.date > Date.today + 1.day
when (@days_of_this_week.include? e.date)
@this_week_exams << e
when (e.date > start_of_other_range)
@other_exams << e
end
end

@today_and_tomorrow_assignments = []
@this_week_assignments = []
@other_assignments = []

current_user.assignments.each do |e|
case
when ((e.due_date == Date.today) or (e.due_date == Date.today + 1.day))
@today_and_tomorrow_assignments << e
when e.due_date > Date.today + 1.day
when (@days_of_this_week.include? e.due_date)
@this_week_assignments << e
when (e.due_date > start_of_other_range)
@other_assignments << e
end
end

@today_and_tomorrow_events = []
@this_week_events = []
@other_events = []
current_user.events.each do |e|

relevant_events = (current_user.events + Event.where(:global => true)).uniq

relevant_events.each do |e|
case
when ((e.date == Date.today) or (e.date == Date.today + 1.day))
@today_and_tomorrow_events << e
when e.date > Date.today + 1.day
when (@days_of_this_week.include? e.date)
@this_week_events << e
when (e.date > start_of_other_range)
@other_events << e
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,6 @@ def set_event

# Never trust parameters from the scary internet, only allow the white list through.
def event_params
params.require(:event).permit(:name, :description, :date)
params.require(:event).permit(:name, :description, :date, :global)
end
end
2 changes: 0 additions & 2 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ def index_activities
@activities = PublicActivity::Activity.order("created_at desc")
end



private
# Use callbacks to share common setup or constraints between actions.
def set_user
Expand Down
5 changes: 5 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ def current_user
nil
end
end

def generate_glyphicon(spclass = "", glyphicon_name)
content_tag(:span, :class => "#{spclass} glyphicon glyphicon-#{glyphicon_name}") do
end
end
end
3 changes: 3 additions & 0 deletions app/helpers/classrooms_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
module ClassroomsHelper
def sort_by_period(classrooms)
return classrooms.sort! { |first, last| first.period <=> last.period }
end
end
2 changes: 2 additions & 0 deletions app/helpers/configuration_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ConfigurationHelper
end
12 changes: 12 additions & 0 deletions app/models/classroom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ def teacher_name=(name)
self.teacher = Teacher.find_or_create_by_name(name) unless name.blank?
end

def day_assignments(day)
self.assignments.select {|assignment| assignment.due_date == day}
end

def day_exams(day)
self.exams.select {|exam| exam.date == day}
end

def day_activities(day)
self.day_assignments(day) + self.day_exams(day)
end

belongs_to :teacher
belongs_to :course
has_many :assignments
Expand Down
3 changes: 3 additions & 0 deletions app/models/configuration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Configuration < ActiveRecord::Base
has_one :user
end
4 changes: 4 additions & 0 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ class Event < ActiveRecord::Base

has_many :attendances
has_many :users, :through => :attendances

def global?
self.global
end
end
32 changes: 32 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,40 @@ def exams
ret
end

def day_assignments(day)
self.assignments.select { |assignment| assignment.due_date == day }
end

def day_exams(day)
self.exams.select { |exam| exam.date == day }
end

def day_events(day)
all_events = (self.events + Event.where(:global => true)).uniq

all_events.select { |event| event.date > day.beginning_of_day && event.date < day.end_of_day }.sort! { |first,last| first.date <=> last.date }
end

def classes
self.classrooms
end

def classes_with_activities_on(day)
self.classrooms.select { |classroom| classroom.day_activities(day).count > 0 }
end

def classes_with_assignments_on(day)
self.classrooms.select { |classroom| classroom.day_assignments(day).count > 0 }
end

def classes_with_exams_on(day)
self.classrooms.select { |classroom| classroom.day_exams(day).count > 0 }
end

has_many :memberships
has_many :classrooms, :through => :memberships
has_many :attendances
has_many :events, :through => :attendances

has_one :configuration
end
2 changes: 1 addition & 1 deletion app/views/classrooms/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<p>
<strong>Members:</strong>
<% @classroom.users.each do |student| %>
<%= link_to student.name, student %>
<%= link_to student.name, student, class: "link-no-underline badge" %>
<% end %>
</p>

Expand Down
2 changes: 2 additions & 0 deletions app/views/configuration/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Configuration#edit</h1>
<p>Find me in app/views/configuration/edit.html.erb</p>
2 changes: 2 additions & 0 deletions app/views/configuration/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Configuration#show</h1>
<p>Find me in app/views/configuration/show.html.erb</p>
2 changes: 2 additions & 0 deletions app/views/configuration/update.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Configuration#update</h1>
<p>Find me in app/views/configuration/update.html.erb</p>
Loading

0 comments on commit 9de36ac

Please sign in to comment.