diff --git a/Gemfile b/Gemfile
index d81643d..1fdf2bd 100755
--- a/Gemfile
+++ b/Gemfile
@@ -12,9 +12,9 @@ gem 'rails', '3.2.9'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
- gem 'sass-rails', '~> 3.2.3'
+ gem 'sass-rails', '~> 3.2'
gem 'coffee-rails', '~> 3.2.1'
- gem 'bootstrap-sass','~> 2.2.0'
+ gem 'bootstrap-sass','~> 2.3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
@@ -77,3 +77,4 @@ gem 'rspec-rails'
end
gem "simple_calendar", "~> 0.1.9"
+gem 'rmagick'
diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss
index 71eebc4..ecbb13d 100755
--- a/app/assets/stylesheets/application.css.scss
+++ b/app/assets/stylesheets/application.css.scss
@@ -10,7 +10,7 @@
*
*= require_self
*= require_tree .
- * require 'bootstrap'
+ *= require 'bootstrap'
*/
$linkColor: #03006E;
@import 'bootstrap';
diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb
index b3631aa..059a7f0 100644
--- a/app/controllers/calendars_controller.rb
+++ b/app/controllers/calendars_controller.rb
@@ -3,7 +3,6 @@ class CalendarsController < ApplicationController
# GET /calendars.json
def index
@calendars = Calendar.all
-
respond_to do |format|
format.html # index.html.erb
format.json { render json: @calendars }
@@ -18,6 +17,7 @@ class CalendarsController < ApplicationController
respond_to do |format|
format.html # show.html.erb
format.json { render json: @calendar }
+ format.ics { render 'show.ics.erb'}
end
end
diff --git a/app/inputs/date_string_input.rb b/app/inputs/date_string_input.rb
index d10e2c9..a70ab33 100644
--- a/app/inputs/date_string_input.rb
+++ b/app/inputs/date_string_input.rb
@@ -1,6 +1,7 @@
class DateStringInput < FormtasticBootstrap::Inputs::StringInput
def input_html_options
- super.merge(:class => "datetext", :onclick =>"beep", :value=>I18n.l(@object.send(method.to_sym)))
+ value = (@object.send(method.to_sym))
+ super.merge(:class => "datetext", :onclick =>"beep", :value=>I18n.l((value.is_a?(Time)||value.is_a?(Date)||value.is_a?(DateTime)) ? value : Time.now))
end
end
diff --git a/app/models/calendar.rb b/app/models/calendar.rb
index eaaa1a9..4f5de1d 100644
--- a/app/models/calendar.rb
+++ b/app/models/calendar.rb
@@ -1,4 +1,5 @@
class Calendar < ActiveRecord::Base
- attr_accessible :name, :public
+ attr_accessible :name, :public, :picture
has_and_belongs_to_many :calentries
+ mount_uploader :picture, PictureUploader
end
diff --git a/app/models/calentry.rb b/app/models/calentry.rb
index 7d7ded6..d6cf59e 100644
--- a/app/models/calentry.rb
+++ b/app/models/calentry.rb
@@ -1,6 +1,13 @@
class Calentry < ActiveRecord::Base
attr_accessible :ende, :start, :summary, :typ,:calendar_ids
- has_and_belongs_to_many :calendar
+ has_and_belongs_to_many :calendars
+ validates :start, :presence => true
+ validates :typ, :presence => true
+ validate do |entry|
+ if entry.ende.nil?
+ errors.add(:ende, "Es muss ein Endzeitpunkt vorhanden sein")
+ end
+ end
def start_time
start
end
diff --git a/app/uploaders/picture_uploader.rb b/app/uploaders/picture_uploader.rb
new file mode 100644
index 0000000..ec0f27a
--- /dev/null
+++ b/app/uploaders/picture_uploader.rb
@@ -0,0 +1,51 @@
+# encoding: utf-8
+
+class PictureUploader < CarrierWave::Uploader::Base
+
+ # Include RMagick or MiniMagick support:
+ include CarrierWave::RMagick
+ # include CarrierWave::MiniMagick
+
+ # Choose what kind of storage to use for this uploader:
+ storage :file
+ # storage :fog
+
+ # Override the directory where uploaded files will be stored.
+ # This is a sensible default for uploaders that are meant to be mounted:
+ def store_dir
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
+ end
+
+ # Provide a default URL as a default if there hasn't been a file uploaded:
+ # def default_url
+ # # For Rails 3.1+ asset pipeline compatibility:
+ # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
+ #
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
+ # end
+
+ # Process files as they are uploaded:
+ # process :scale => [200, 300]
+ #
+ # def scale(width, height)
+ # # do something
+ # end
+
+ # Create different versions of your uploaded files:
+ version :thumb do
+ process :resize_to_fill => [64, 64]
+ end
+
+ # Add a white list of extensions which are allowed to be uploaded.
+ # For images you might use something like this:
+ def extension_white_list
+ %w(jpg jpeg gif png)
+ end
+
+ # Override the filename of the uploaded files:
+ # Avoid using model.id or version_name here, see uploader/store.rb for details.
+ # def filename
+ # "something.jpg" if original_filename
+ # end
+
+end
diff --git a/app/views/calendars/_form.html.erb b/app/views/calendars/_form.html.erb
index dc6e021..139e9d8 100644
--- a/app/views/calendars/_form.html.erb
+++ b/app/views/calendars/_form.html.erb
@@ -2,6 +2,7 @@
<%= f.inputs do %>
<%= f.input :name %>
<%= f.input :public %>
+ <%= f.input :picture, :as => :file %>
<% end %>
<%= f.actions do %>
diff --git a/app/views/calendars/index.html.erb b/app/views/calendars/index.html.erb
index 402c093..8d6c591 100644
--- a/app/views/calendars/index.html.erb
+++ b/app/views/calendars/index.html.erb
@@ -1,25 +1,14 @@
Listing calendars
-
-
- | Name |
- Public |
- |
- |
- |
-
-
<% @calendars.each do |calendar| %>
-
- | <%= calendar.name %> |
- <%= calendar.public %> |
- <%= link_to 'Show', calendar %> |
- <%= link_to 'Edit', edit_calendar_path(calendar) %> |
- <%= link_to 'Destroy', calendar, method: :delete, data: { confirm: 'Are you sure?' } %> |
-
+
<% end %>
-
-
-
<%= link_to 'New Calendar', new_calendar_path %>
diff --git a/app/views/calendars/show.html.erb b/app/views/calendars/show.html.erb
index 8778ca8..0c7e038 100644
--- a/app/views/calendars/show.html.erb
+++ b/app/views/calendars/show.html.erb
@@ -1,24 +1,30 @@
+
+
<%= notice %>
-
- Name:
- <%= @calendar.name %>
-
-
-
- Public:
- <%= @calendar.public %>
-
-
-
+
+ <%= ''.html_safe unless !@calendar.public%>
+ <%= @calendar.name %>
+
+
+
<% @calendar.calentries.each do |entry| %>
-<%= entry.summary+ "- " + entry.start.to_s %>
+-
+<%= link_to entry.summary+ " - " + I18n.l(entry.start), entry %>
+
<% end %>
-
+
+
+
<%= calendar @calendar.calentries do |entry| %>
<%= link_to entry.name, entry %>
<% end %>
-
-<%= link_to 'New Entry', new_calentry_path %>
-<%= link_to 'Edit', edit_calendar_path(@calendar) %> |
-<%= link_to 'Back', calendars_path %>
+
+
+
+<%= link_to 'New Entry', new_calentry_path, {:class=>"btn"} %>
+<%= link_to 'Edit', edit_calendar_path(@calendar), {:class=>"btn"} %>
+<%= link_to 'Back', calendars_path, {:class=>"btn"} %>
+
+
+
diff --git a/app/views/calendars/show.ics.erb b/app/views/calendars/show.ics.erb
new file mode 100644
index 0000000..8d3126f
--- /dev/null
+++ b/app/views/calendars/show.ics.erb
@@ -0,0 +1,3 @@
+<% @calendar.calentries.each do |entry| %>
+<%= render entry %>
+<% end %>
diff --git a/app/views/calentries/_calentry.ics.erb b/app/views/calentries/_calentry.ics.erb
new file mode 100644
index 0000000..dead832
--- /dev/null
+++ b/app/views/calentries/_calentry.ics.erb
@@ -0,0 +1,5 @@
+ <%= calentry.start %>
+ <%= calentry.ende %>
+ <%= calentry.summary %>
+ <%= calentry.typ %>
+
diff --git a/app/views/calentries/_form.html.erb b/app/views/calentries/_form.html.erb
index 5306d58..eb9bb02 100644
--- a/app/views/calentries/_form.html.erb
+++ b/app/views/calentries/_form.html.erb
@@ -1,13 +1,34 @@
+
<%= semantic_form_for @calentry do |f| %>
<%= f.inputs do %>
+
+
<%= f.input :start , :as => :date_string %>
- <%= f.input :ende %>
+
+
+ <%= f.input :ende , :as => :date_string %>
+
+
+
+
<%= f.input :summary %>
- <%= f.input :calendar, :as=> :radio %>
+
+
+
+
+ <%= f.input :calendars, :as=> :radio %>
+
+
<%= f.input :typ %>
+
+
<% end %>
-
+
+
<%= f.actions do %>
<%= f.action :submit, :as => :input %>
<% end %>
+
+
<% end %>
+
diff --git a/app/views/calentries/show.html.erb b/app/views/calentries/show.html.erb
index 908d8dc..faa5c9c 100644
--- a/app/views/calentries/show.html.erb
+++ b/app/views/calentries/show.html.erb
@@ -1,25 +1,25 @@
<%= notice %>
-
-
- Start:
- <%= @calentry.start %>
-
-
-
- Ende:
- <%= @calentry.ende %>
-
-
-
- Summary:
+
+
+
+
<%= @calentry.summary %>
-
+
-
- Typ:
+
+
+
+
+ <%= I18n.l @calentry.start %>
+ <%= " bis " unless @calentry.ende.nil? %>
+ <%= I18n.l @calentry.ende %>
+
+
<%= @calentry.typ %>
-
-
+
+
+
<%= link_to 'Edit', edit_calentry_path(@calentry) %> |
<%= link_to 'Back', calentries_path %>
+
diff --git a/db/migrate/20130810214456_add_picture_to_calendars.rb b/db/migrate/20130810214456_add_picture_to_calendars.rb
new file mode 100644
index 0000000..d1b4b44
--- /dev/null
+++ b/db/migrate/20130810214456_add_picture_to_calendars.rb
@@ -0,0 +1,5 @@
+class AddPictureToCalendars < ActiveRecord::Migration
+ def change
+ add_column :calendars, :picture, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 6a96d37..b8d0781 100755
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,23 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20130729085446) do
+ActiveRecord::Schema.define(:version => 20130810214456) do
+
+ create_table "attachments", :force => true do |t|
+ t.string "name"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ create_table "beispiel_translations", :force => true do |t|
+ t.string "locale"
+ t.text "desc"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.integer "beispiele_id"
+ end
+
+ add_index "beispiel_translations", ["locale"], :name => "index_beispiel_translations_on_locale"
create_table "beispiele", :force => true do |t|
t.string "name"
@@ -22,6 +38,38 @@ ActiveRecord::Schema.define(:version => 20130729085446) do
t.string "beispieldatei"
end
+ create_table "calendars", :force => true do |t|
+ t.string "name"
+ t.boolean "public"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.string "picture"
+ end
+
+ create_table "calendars_calentries", :id => false, :force => true do |t|
+ t.integer "calentry_id"
+ t.integer "calendar_id"
+ end
+
+ add_index "calendars_calentries", ["calendar_id"], :name => "index_calendars_calentries_on_calendar_id"
+ add_index "calendars_calentries", ["calentry_id", "calendar_id"], :name => "index_calendars_calentries_on_calentry_id_and_calendar_id"
+
+ create_table "calentries", :force => true do |t|
+ t.datetime "start"
+ t.datetime "ende"
+ t.string "summary"
+ t.integer "typ"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ create_table "fragen", :force => true do |t|
+ t.string "title"
+ t.text "text"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
create_table "lva_translations", :force => true do |t|
t.integer "lva_id"
t.string "locale"
@@ -50,11 +98,14 @@ ActiveRecord::Schema.define(:version => 20130729085446) do
t.integer "modul_id"
end
- create_table "lvas_semesters", :force => true do |t|
+ create_table "lvas_semesters", :id => false, :force => true do |t|
t.integer "lva_id"
t.integer "semester_id"
end
+ add_index "lvas_semesters", ["lva_id", "semester_id"], :name => "index_lvas_semesters_on_lva_id_and_semester_id"
+ add_index "lvas_semesters", ["semester_id"], :name => "index_lvas_semesters_on_semester_id"
+
create_table "modul_translations", :force => true do |t|
t.integer "modul_id"
t.string "locale"
@@ -161,6 +212,20 @@ ActiveRecord::Schema.define(:version => 20130729085446) do
add_index "studium_translations", ["locale"], :name => "index_studium_translations_on_locale"
+ create_table "themen", :force => true do |t|
+ t.string "title"
+ t.text "text"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ create_table "themengruppen", :force => true do |t|
+ t.string "title"
+ t.text "text"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
create_table "users", :force => true do |t|
t.string "email", :default => "", :null => false
t.string "encrypted_password", :default => "", :null => false
diff --git a/spec/models/calentry_spec.rb b/spec/models/calentry_spec.rb
index 0e3a169..02e654e 100644
--- a/spec/models/calentry_spec.rb
+++ b/spec/models/calentry_spec.rb
@@ -1,5 +1,20 @@
require 'spec_helper'
describe Calentry do
- pending "add some examples to (or delete) #{__FILE__}"
+ it "should be valid with full data" do
+ e = FactoryGirl.build(:calentry)
+ c = FactoryGirl.create(:calendar)
+ e.calendars<
nil)
+ c=FactoryGirl.create(:calendar)
+ e.calendars<