diff --git a/.gitignore b/.gitignore index 9679a17..a978807 100755 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ # Ignore the default SQLite database. /db/*.sqlite3 +/db/schema.rb +/db/structure.sql /config/initializers/devise.rb # Ignore all logfiles and tempfiles. @@ -16,6 +18,7 @@ /tmp /config/initializers/devise.rb /app/doc/* + console /server /public/uploads/ diff --git a/Gemfile b/Gemfile index 7fce64e..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' @@ -75,3 +75,6 @@ group :development, :test do gem 'factory_girl_rails' gem 'rspec-rails' end + +gem "simple_calendar", "~> 0.1.9" +gem 'rmagick' diff --git a/Gemfile.lock b/Gemfile.lock index 2f98cfb..ff6d52b 100755 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -35,7 +35,7 @@ GEM activerecord (>= 3.0.0) bcrypt-ruby (3.0.1) bcrypt-ruby (3.0.1-x86-mingw32) - bootstrap-sass (2.2.2.0) + bootstrap-sass (2.3.2.1) sass (~> 3.2) builder (3.0.4) cancan (1.6.9) @@ -128,6 +128,7 @@ GEM rdoc (3.12.1) json (~> 1.4) ref (1.0.2) + rmagick (2.13.2) rolify (3.2.0) rspec-core (2.14.4) rspec-expectations (2.14.0) @@ -145,6 +146,8 @@ GEM railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) + simple_calendar (0.1.9) + rails (>= 3.0) sprockets (2.2.2) hike (~> 1.2) multi_json (~> 1.0) @@ -176,7 +179,7 @@ PLATFORMS DEPENDENCIES annotate (>= 2.5.0) awesome_nested_set - bootstrap-sass (~> 2.2.0) + bootstrap-sass (~> 2.3.2.1) cancan carrierwave coffee-rails (~> 3.2.1) @@ -192,9 +195,11 @@ DEPENDENCIES paper_trail (>= 2.7.0) paperclip (~> 3.4.0) rails (= 3.2.9) + rmagick rolify rspec-rails - sass-rails (~> 3.2.3) + sass-rails (~> 3.2) + simple_calendar (~> 0.1.9) sqlite3 therubyracer tinymce-rails (>= 3.5.8) diff --git a/app/assets/javascripts/calendars.js.coffee b/app/assets/javascripts/calendars.js.coffee new file mode 100644 index 0000000..7615679 --- /dev/null +++ b/app/assets/javascripts/calendars.js.coffee @@ -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://jashkenas.github.com/coffee-script/ diff --git a/app/assets/javascripts/calentries.js.coffee b/app/assets/javascripts/calentries.js.coffee new file mode 100644 index 0000000..7615679 --- /dev/null +++ b/app/assets/javascripts/calentries.js.coffee @@ -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://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 71eebc4..ab46a0b 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'; @@ -30,7 +30,8 @@ border-bottom:1px solid black; height:60px; padding-left:160px; padding-top:0px; -overflow:hidden +overflow:hidden; +margin-bottom: 20px } #menudiv diff --git a/app/assets/stylesheets/bootstrap-responsive.scss b/app/assets/stylesheets/bootstrap-responsive.scss new file mode 100644 index 0000000..f2950bd --- /dev/null +++ b/app/assets/stylesheets/bootstrap-responsive.scss @@ -0,0 +1,5 @@ +@import "bootstrap/responsive"; +@media (max-width: 979px){ +.earlymax { +min-width: 100%; +}} diff --git a/app/assets/stylesheets/calendars.css.scss b/app/assets/stylesheets/calendars.css.scss new file mode 100644 index 0000000..0efb58b --- /dev/null +++ b/app/assets/stylesheets/calendars.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the calendars controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/calentries.css.scss b/app/assets/stylesheets/calentries.css.scss new file mode 100644 index 0000000..47a2dcd --- /dev/null +++ b/app/assets/stylesheets/calentries.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the calentries controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/formtastic-changes.css.scss b/app/assets/stylesheets/formtastic-changes.css.scss new file mode 100644 index 0000000..2b1ad2b --- /dev/null +++ b/app/assets/stylesheets/formtastic-changes.css.scss @@ -0,0 +1,15 @@ +form.formtastic .stringish input { +width:90%; +} +form.formtastic select { +width:90% +} +form.formtastic textarea { +width:90%; +height:20em; +} +form.formtastic .input label.control-label { +font-weight:bold; +font-size:125%; +} + diff --git a/app/assets/stylesheets/lvas.css.scss b/app/assets/stylesheets/lvas.css.scss index 797b72c..9084fc3 100755 --- a/app/assets/stylesheets/lvas.css.scss +++ b/app/assets/stylesheets/lvas.css.scss @@ -1,3 +1,27 @@ // Place all the styles related to the lvas controller here. // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ + +div.lva-semester { +border: solid; +border-width: 1px; +margin: 1px; +padding: 5px; +border-color: green; +border-radius: 5px; +} +div.lva-sidebar { +border:solid; +border-width: 1px; +margin: 2px; +padding:5px; +border-radius:5px; +} +div.lva-beispiele { +border:solid; +border-width: 1px; +margin: 2px; +padding:5px; +border-radius:5px; +border-color: green; +} \ No newline at end of file diff --git a/app/assets/stylesheets/studien.css.scss b/app/assets/stylesheets/studien.css.scss index 7b5973a..5c788c2 100755 --- a/app/assets/stylesheets/studien.css.scss +++ b/app/assets/stylesheets/studien.css.scss @@ -1,3 +1,18 @@ // Place all the styles related to the studia controller here. // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ +div.verwalten-block { +border-width: 1px; +border-style: solid; +padding: 5px; +border-radius:10px; +margin: 2px; +} +div.studien-semester { +border-width: 1px; +border-style: solid; +padding: 5px; +border-radius:10px; +border-color: blue; +margin: 2px; +} diff --git a/app/controllers/beispiele_controller.rb b/app/controllers/beispiele_controller.rb index ccd30a3..0f88686 100755 --- a/app/controllers/beispiele_controller.rb +++ b/app/controllers/beispiele_controller.rb @@ -26,7 +26,8 @@ class BeispieleController < ApplicationController # GET /beispiele/new.json def new @beispiel = Beispiel.new - @beispiel.lva_id = params[:lva_id] + @beispiel.lva = Lva.find(params[:lva_id]) + respond_to do |format| format.html # new.html.erb format.json { render json: @beispiel } @@ -41,8 +42,9 @@ class BeispieleController < ApplicationController # POST /beispiele # POST /beispiele.json def create + lvaid=params[:lva_id] + params.delete(:lva_id) @beispiel = Beispiel.new(params[:beispiel]) - respond_to do |format| if @beispiel.save format.html { redirect_to @beispiel, notice: 'Beispiel was successfully created.' } diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb new file mode 100644 index 0000000..059a7f0 --- /dev/null +++ b/app/controllers/calendars_controller.rb @@ -0,0 +1,83 @@ +class CalendarsController < ApplicationController + # GET /calendars + # GET /calendars.json + def index + @calendars = Calendar.all + respond_to do |format| + format.html # index.html.erb + format.json { render json: @calendars } + end + end + + # GET /calendars/1 + # GET /calendars/1.json + def show + @calendar = Calendar.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @calendar } + format.ics { render 'show.ics.erb'} + end + end + + # GET /calendars/new + # GET /calendars/new.json + def new + @calendar = Calendar.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @calendar } + end + end + + # GET /calendars/1/edit + def edit + @calendar = Calendar.find(params[:id]) + end + + # POST /calendars + # POST /calendars.json + def create + @calendar = Calendar.new(params[:calendar]) + + respond_to do |format| + if @calendar.save + format.html { redirect_to @calendar, notice: 'Calendar was successfully created.' } + format.json { render json: @calendar, status: :created, location: @calendar } + else + format.html { render action: "new" } + format.json { render json: @calendar.errors, status: :unprocessable_entity } + end + end + end + + # PUT /calendars/1 + # PUT /calendars/1.json + def update + @calendar = Calendar.find(params[:id]) + + respond_to do |format| + if @calendar.update_attributes(params[:calendar]) + format.html { redirect_to @calendar, notice: 'Calendar was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @calendar.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /calendars/1 + # DELETE /calendars/1.json + def destroy + @calendar = Calendar.find(params[:id]) + @calendar.destroy + + respond_to do |format| + format.html { redirect_to calendars_url } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/calentries_controller.rb b/app/controllers/calentries_controller.rb new file mode 100644 index 0000000..3452d72 --- /dev/null +++ b/app/controllers/calentries_controller.rb @@ -0,0 +1,84 @@ +class CalentriesController < ApplicationController + # GET /calentries + # GET /calentries.json + def index + @calentries = Calentry.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @calentries } + end + end + + # GET /calentries/1 + # GET /calentries/1.json + def show + @calentry = Calentry.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @calentry } + format.ics { render 'show.ics.erb'} + end + end + + # GET /calentries/new + # GET /calentries/new.json + def new + @calentry = Calentry.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @calentry } + end + end + + # GET /calentries/1/edit + def edit + @calentry = Calentry.find(params[:id]) + end + + # POST /calentries + # POST /calentries.json + def create + @calentry = Calentry.new(params[:calentry]) + + respond_to do |format| + if @calentry.save + format.html { redirect_to @calentry, notice: 'Calentry was successfully created.' } + format.json { render json: @calentry, status: :created, location: @calentry } + else + format.html { render action: "new" } + format.json { render json: @calentry.errors, status: :unprocessable_entity } + end + end + end + + # PUT /calentries/1 + # PUT /calentries/1.json + def update + @calentry = Calentry.find(params[:id]) + + respond_to do |format| + if @calentry.update_attributes(params[:calentry]) + format.html { redirect_to @calentry, notice: 'Calentry was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @calentry.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /calentries/1 + # DELETE /calentries/1.json + def destroy + @calentry = Calentry.find(params[:id]) + @calentry.destroy + + respond_to do |format| + format.html { redirect_to calentries_url } + format.json { head :no_content } + end + end +end diff --git a/app/controllers/lvas_controller.rb b/app/controllers/lvas_controller.rb index 7b737dd..d2ee71f 100755 --- a/app/controllers/lvas_controller.rb +++ b/app/controllers/lvas_controller.rb @@ -16,14 +16,6 @@ class LvasController < ApplicationController @toolbar_elements<<{:hicon=>'icon-plus-sign', :icon=>:plus, :text => "Neues Beispiel", :path=> new_beispiel_path(:lva_id =>@lva.id)} @toolbar_elements<<{:hicon=>'icon-pencil', :icon=>:pencil,:text =>I18n.t('common.edit'),:path => edit_lva_path(@lva)} - @topbar_elements =[{:hicon=>'icon-list', :text=>I18n.t("lva.list"), :path=>lvas_path}] - for m in @lva.modul - @topbar_elements << {:newline=>true} - @topbar_elements << {:text=> '' + m.name + '', :path=>modul_path(m)} - for mg in m.modulgruppen - @topbar_elements << {:text => mg.studium.name + ' (' + mg.name + ')', :path=>studium_path(mg.studium)} - end - end end # GET /lvas/new diff --git a/app/controllers/modulgruppen_controller.rb b/app/controllers/modulgruppen_controller.rb index c69f8fe..d84de6f 100755 --- a/app/controllers/modulgruppen_controller.rb +++ b/app/controllers/modulgruppen_controller.rb @@ -51,15 +51,10 @@ class ModulgruppenController < ApplicationController def create @modulgruppe = Modulgruppe.new(params[:modulgruppe]) - if !params[:studium_id].nil? - @studium=Studium.find_by_id(params[:studium_id]) - else - @studium=Studium.find_by_id(params[:modulgruppe][:studium_id]) - end respond_to do |format| if @modulgruppe.save - format.html { redirect_to @studium, notice: 'Modulgruppe was successfully created.' } + format.html { redirect_to @modulgruppe.studium, notice: 'Modulgruppe was successfully created.' } else format.html { render action: "new" } diff --git a/app/controllers/semesters_controller.rb b/app/controllers/semesters_controller.rb index 751a4b7..8a527c4 100755 --- a/app/controllers/semesters_controller.rb +++ b/app/controllers/semesters_controller.rb @@ -16,6 +16,7 @@ class SemestersController < ApplicationController def edit @semester = Semester.find(params[:id]) + @studium = @semester.studium end def create @@ -33,7 +34,7 @@ class SemestersController < ApplicationController def update @semester = Semester.find(params[:id]) - + @studium= @semester.studium respond_to do |format| if @semester.update_attributes(params[:semester]) format.html { redirect_to @semester, notice: 'Semester was successfully updated.' } diff --git a/app/controllers/studien_controller.rb b/app/controllers/studien_controller.rb index fb0ae58..f5b9d63 100755 --- a/app/controllers/studien_controller.rb +++ b/app/controllers/studien_controller.rb @@ -1,6 +1,6 @@ class StudienController < ApplicationController before_filter {@toolbar_elements =[]} - + # before_filter :authorize, :only => :verwalten def index @studien = Studium.all @@ -39,10 +39,10 @@ class StudienController < ApplicationController @toolbar_modulgruppen =[ {:hicon=>'icon-plus-sign', :text=> I18n.t('modulgruppe.new'), :path=>new_studium_modulgruppe_path(@studium)}, {:hicon=>'icon-list', :text => I18n.t('modulgruppe.list'), :path=>modulgruppen_path}] - if params[:ansicht] == 'semesteransicht' + if params[:ansicht] != 'modulgruppenansicht' @text = 'Zu Modulansicht wechseln' @flip = 'modulgruppenansicht' - render 'semesteransicht' + render 'semesteransicht' else @text = 'Zu Semesteransicht wechseln' @flip = 'semesteransicht' @@ -90,7 +90,147 @@ class StudienController < ApplicationController @studium.destroy redirect_to studien_url end + + def verwalten + @new_params={:std_verw=>params[:std_verw], :mg_verw=>params[:mg_verw], :m_verw=>params[:m_verw], :lva_verw=>params[:lva_verw], :b_verw=>params[:b_verw]} + if @new_params.values.compact.empty? + @studien=Studium.all + @modulgruppen=Modulgruppe.all + @module=Modul.all + @lvas=Lva.all + @beispiele=Beispiel.all + else + if !@new_params[:std_verw].nil? + @studien = [Studium.find(@new_params[:std_verw])] + else + @studien = Studium.all + end + if !@new_params[:mg_verw].nil? + @modulgruppen = [Modulgruppe.find(@new_params[:mg_verw])] + temp = @modulgruppen.map{|x| x.studium}.flatten.uniq # Force Studien + @studien=@studien.select{|k| temp.include?(k)} + + else + @modulgruppen = Modulgruppe.all + temp = @studien.map{|x| x.modulgruppen}.flatten.uniq # Studien forcen Modulgruppen + @modulgruppen = @modulgruppen.select{|k| temp.include?(k)} + end + if !@new_params[:m_verw].nil? + @module = [Modul.find(@new_params[:m_verw])] + temp = @module.map{|x| x.modulgruppen}.flatten.uniq # Force Modulgruppen + @modulgruppen = @modulgruppen.select{|k| temp.include?(k)} + temp = @modulgruppen.map{|x| x.studium}.flatten.uniq # Force Studien + @studien=@studien.select{|k| temp.include?(k)} + + else + @module = Modul.all + temp = @modulgruppen.map{|x| x.moduls}.flatten.uniq + @module=@module.select{|k| temp.include?(k)} + end + if !@new_params[:lva_verw].nil? + @lvas = [Lva.find(@new_params[:lva_verw])] + temp = @lvas.map{|x| x.modul}.flatten.uniq + @module=@module.select{|k| temp.include?(k)} + temp = @module.map{|x| x.modulgruppen}.flatten.uniq # Force Modulgruppen + @modulgruppen = @modulgruppen.select{|k| temp.include?(k)} + temp = @modulgruppen.map{|x| x.studium}.flatten.uniq # Force Studien + @studien=@studien.select{|k| temp.include?(k)} + else + @lvas = Lva.all + temp = @module.map{|x| x.lvas}.flatten.uniq #Force Module + @lvas=@lvas.select{|k| temp.include?(k)} + end + if !@new_params[:b_verw].nil? + @beispiele = [Beispiel.find(@new_params[:b_verw])] + temp = @lvas.map{|x| x.beispiele}.flatten.uniq #Force Force Lvas + @lvas=@lvas.select{|k| temp.include?(k)} + temp = @module.map{|x| x.lvas}.flatten.uniq #Force Module + @module=@module.select{|k| temp.include?(k)} + temp = @module.map{|x| x.modulgruppen}.flatten.uniq # Force Modulgruppen + @modulgruppen = @modulgruppen.select{|k| temp.include?(k)} + temp = @modulgruppen.map{|x| x.studium}.flatten.uniq # Force Studien + @studien=@studien.select{|k| temp.include?(k)} + + + else + @beispiele = Beispiel.all + temp = @lvas.map{|x| x.beispiele}.flatten.uniq # Force beispiel + @beispiele=@beispiele.select{|k| temp.include?(k)} + end + end + + @messages = [] + for s in @studien + + if s.valid? + @messages << s.name + ' hat keine Modulgruppe' if s.modulgruppen.count == 0 + + else + @messages << ''+s.name + ': ' + @messages << s.errors.full_messages + @messages << '' + end + end + for mg in @modulgruppen + + if mg.valid? + @messages << mg.name + ' hat kein Modul' if mg.moduls.count == 0 + else + @messages << ''+mg.name + ': ' + @messages << mg.errors.full_messages + @messages << '' + end + end + for m in @module + + if m.valid? + @messages << m.name.to_s + ' hat keine Modulgruppe' if m.modulgruppen.count == 0 + @messages << m.name.to_s + ' hat keine Lvas' if m.lvas.count == 0 + else + @messages << ''+m.name.to_s + ': ' + @messages << m.errors.full_messages + @messages << '' + end + end + for lva in @lvas + + if lva.valid? + @messages << lva.name + ' hat keine Module' if lva.modul.count == 0 + for s in @studien + stu_sem = s.semester.map{|l| l.lvas}.flatten.uniq.index(lva) + stu_mod = s.modulgruppen.map{|m| m.moduls}.flatten.map{|l| l.lvas}.flatten.uniq.index(lva) + if (stu_sem.nil? && !stu_mod.nil?) + @messages << lva.name + ' erscheint nicht in der Semesteransicht von ' +s.name + ' aber in der Modulgruppenansicht' + end + if (!stu_sem.nil? && stu_mod.nil?) + @messages << lva.name + ' erscheint in der Semesteransicht von ' +s.name + ' aber nicht in der Modulgruppenansicht' + end + end + else + @messages << ''+lva.name + ': ' + @messages << lva.errors.full_messages + @messages << '' + end + end + for b in @beispiele + if b.valid? + @messages << b.name + ' hat keine Lva' if b.lva.nil? + else + @messages << ''+b.name + ': ' + @messages << b.errors.full_messages + @messages << '' + end + end + render 'studien/verwalten' + end + def default_url_options - {ansicht: params[:ansicht]}.merge(super) + {:ansicht=> params[:ansicht], + :std_verw=> params[:std_verw], + :mg_verw=> params[:mg_verw], + :m_verw=>params[:m_verw], + :lva_verw=>params[:lva_verw], + :b_verw=>params[:b_verw]}.merge(super) + end end diff --git a/app/helpers/calendars_helper.rb b/app/helpers/calendars_helper.rb new file mode 100644 index 0000000..9712f62 --- /dev/null +++ b/app/helpers/calendars_helper.rb @@ -0,0 +1,2 @@ +module CalendarsHelper +end diff --git a/app/helpers/calentries_helper.rb b/app/helpers/calentries_helper.rb new file mode 100644 index 0000000..b46fa94 --- /dev/null +++ b/app/helpers/calentries_helper.rb @@ -0,0 +1,2 @@ +module CalentriesHelper +end diff --git a/app/inputs/date_string_input.rb b/app/inputs/date_string_input.rb new file mode 100644 index 0000000..a70ab33 --- /dev/null +++ b/app/inputs/date_string_input.rb @@ -0,0 +1,7 @@ +class DateStringInput < FormtasticBootstrap::Inputs::StringInput + def input_html_options + 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 new file mode 100644 index 0000000..4f5de1d --- /dev/null +++ b/app/models/calendar.rb @@ -0,0 +1,5 @@ +class Calendar < ActiveRecord::Base + 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 new file mode 100644 index 0000000..47f90ee --- /dev/null +++ b/app/models/calentry.rb @@ -0,0 +1,20 @@ +class Calentry < ActiveRecord::Base + attr_accessible :ende, :start, :summary, :typ,:calendar_ids + 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 + def start1 + start.to_date + end + def name + summary + end +end diff --git a/app/models/lva.rb b/app/models/lva.rb index 86d1c5c..411d913 100755 --- a/app/models/lva.rb +++ b/app/models/lva.rb @@ -16,8 +16,9 @@ # class Lva < ActiveRecord::Base + ERLAUBTE_TYPEN = ['VO', 'UE', 'VU', 'LU', 'SE', 'andere']; has_paper_trail # Versionsverfolgung - attr_accessible :desc, :ects, :lvanr, :name, :stunden, :modul_ids, :semester_ids + attr_accessible :desc, :ects, :lvanr, :name, :stunden, :modul_ids, :semester_ids, :pruefungsinformation, :lernaufwand, :typ has_and_belongs_to_many :modul # Gehört zu einem Modul has_and_belongs_to_many :semester #Gehört zu einem Semester( derzeit nicht implementiert) @@ -27,8 +28,8 @@ class Lva < ActiveRecord::Base validates :lvanr,:format=>{ :with => /^[0-9][0-9][0-9]\.[0-9][0-9][0-9]$/}, :presence=>true, :uniqueness=>true # , :uniqueness=>true # LVA-Nummer muss das Format 000.000 besitzen (uniqueness?) oder 000 für nicht validates_presence_of :ects # ECTS vorhanden? - validates :name, :presence=>true - validates :name, :uniqueness=>true# Name Eingetragen? + validates :name, :presence=>true, :uniqueness=>true# Name Eingetragen? + validates :typ, :presence=>true, :inclusion=> ERLAUBTE_TYPEN validates_presence_of :stunden # Stunden Eingetragen? validates_presence_of :modul # Zugehöriges Modul eingetragen? (zumindest eines) def add_semesters diff --git a/app/models/modulgruppe.rb b/app/models/modulgruppe.rb index dc3787b..236811c 100755 --- a/app/models/modulgruppe.rb +++ b/app/models/modulgruppe.rb @@ -13,7 +13,7 @@ # class Modulgruppe < ActiveRecord::Base - attr_accessible :name, :phase, :typ,:desc, :studium_id + attr_accessible :name, :phase, :typ,:desc, :studium_id, :modul_ids belongs_to :studium, :foreign_key => "studium_id" has_and_belongs_to_many :moduls diff --git a/app/models/studium.rb b/app/models/studium.rb index 94177f9..be8f3be 100755 --- a/app/models/studium.rb +++ b/app/models/studium.rb @@ -12,14 +12,17 @@ # created_at :datetime not null # updated_at :datetime not null class Studium < ActiveRecord::Base - attr_accessible :desc, :name, :typ, :zahl + attr_accessible :desc, :name,:abkuerzung, :typ, :zahl, :semester has_many :modulgruppen, inverse_of: :studium, :class_name => "Modulgruppe", :dependent => :destroy has_many :semester, :dependent => :destroy - + validates :abkuerzung, :length=>{:maximum=>5}, :format=>{:with=>/^[a-zA-z]{0,5}$/} validates :typ, :inclusion => {:in => ["Bachelor","Master"] } validates :name, :uniqueness => true, :presence=>true validates :zahl, :presence=>true, :format=>{:with=>/^0(33|66)[0-9]{3}$/}, :uniqueness => true translates :desc,:shortdesc, :versioning =>true,:fallbacks_for_empty_translations => true + def title_context + return self.abkuerzung.to_s.strip.empty? ? self.name : self.abkuerzung + end def batch_add_semester # Semester automatisch zu Studien hinzufügen 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/beispiele/_beispiel.html.erb b/app/views/beispiele/_beispiel.html.erb index 740e496..07c9cf9 100644 --- a/app/views/beispiele/_beispiel.html.erb +++ b/app/views/beispiele/_beispiel.html.erb @@ -1,4 +1,4 @@ -
+ <%= @beispiel.lva.name %> +
<%= link_to 'Edit', edit_beispiel_path(@beispiel) %> | <%= link_to 'Back', beispiele_path %> diff --git a/app/views/calendars/_form.html.erb b/app/views/calendars/_form.html.erb new file mode 100644 index 0000000..139e9d8 --- /dev/null +++ b/app/views/calendars/_form.html.erb @@ -0,0 +1,11 @@ +<%= semantic_form_for @calendar do |f| %> + <%= f.inputs do %> + <%= f.input :name %> + <%= f.input :public %> + <%= f.input :picture, :as => :file %> + <% end %> + + <%= f.actions do %> + <%= f.action :submit, :as => :input %> + <% end %> +<% end %> diff --git a/app/views/calendars/edit.html.erb b/app/views/calendars/edit.html.erb new file mode 100644 index 0000000..e882347 --- /dev/null +++ b/app/views/calendars/edit.html.erb @@ -0,0 +1,6 @@ +<%= notice %>
+ +| Start | +Ende | +Summary | +Typ | ++ | + | + |
|---|---|---|---|---|---|---|
| <%= calentry.start %> | +<%= calentry.ende %> | +<%= calentry.summary %> | +<%= calentry.typ %> | +<%= link_to 'Show', calentry %> | +<%= link_to 'Edit', edit_calentry_path(calentry) %> | +<%= link_to 'Destroy', calentry, method: :delete, data: { confirm: 'Are you sure?' } %> | +
<%= notice %>
+<%= notice %>
+ ++ Start: + <%= @calentry.start %> +
+ ++ Ende: + <%= @calentry.ende %> +
+ ++ Summary: + <%= @calentry.summary %> +
+ ++ Typ: + <%= @calentry.typ %> +
+ + +<%= link_to 'Edit', edit_calentry_path(@calentry) %> | +<%= link_to 'Back', calentries_path %> diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 4d56fdb..6e2e796 100755 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1,3 +1,21 @@Die Webseite befindet sich derzeit in einem Entsicklungsstadium, +volle Funktionsfähigkeit ist noch nicht erreicht. Bitte Featurerequests und +Fehlermeldungen auf GitHub melden. +
++<%= link_to "Issues", "http://www.github.com/fetsite/fetsite/issues" %> +
++Folgene Features sind schon soweit, dass Bugreports sinnvoll sind: +
<%= link_to "Steuerelemente und Komponenten", "http://getbootstrap.com/2.3.2/index.html" %>
+<%= t 'home.hallobeiderfet' %>
<%= link_to "Entwicklungsstatus" , home_dev_path %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 8e3d2d2..83b766f 100755 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,6 +1,8 @@ - + + ++
<%= notice %>
-- -
<%= notice %>
+<%= notice %>
-<% if !modul.name.nil? %><%= link_to "Modul "+ modul.name , modul_path(modul) %> <%end%>
-- <%= raw(modul.desc) %> -
- <% link_to ''.html_safe+I18n.t("common.edit"), edit_modul_path(modul) %>- <%= -if modul.name.nil? -name="" -else -name=modul.name -end -link_to "Modul "+name , modul_path(modul) %> -
+ +- <%= raw(modul.desc) %> + <%= raw(@modul.desc) %>
-LVAs: -<%= notice %>
<%= render @modul %> <%= render 'layouts/pretty_toolbar' %> -<% # link_to 'Add LVA', %> -<% # link_to ''.html_safe+ I18n.t("common.edit") , edit_modul_path(@modul) %> -<% # link_to "Loeschen", [@modul],:method=>:delete ,:data => {:confirm =>"Are you sure" } %> diff --git a/app/views/semesters/_form.html.erb b/app/views/semesters/_form.html.erb index 710e4ea..7ff4d18 100755 --- a/app/views/semesters/_form.html.erb +++ b/app/views/semesters/_form.html.erb @@ -1,12 +1,11 @@ <%= semantic_form_for @semester do |f| %> <%= f.inputs do %> - <%= f.input :name %> - <%= f.input :nummer %> - <%= f.input :ssws %> - <%= f.input :lvas %> + <%= f.input :lvas, :as=>:check_boxes%> <% end %> <%= f.actions do %> <%= f.action :submit, :as => :input %> <% end %> <% end %> +<%= link_to 'Zurück',@studium, :class=>"btn"%> +x diff --git a/app/views/semesters/edit.html.erb b/app/views/semesters/edit.html.erb index 10925ec..bf39462 100755 --- a/app/views/semesters/edit.html.erb +++ b/app/views/semesters/edit.html.erb @@ -1,6 +1,3 @@ -" do + render + # Run the generator again with the --webrat flag if you want to use webrat matchers + rendered.should match(/Name/) + rendered.should match(/false/) + end +end diff --git a/spec/views/calentries/edit.html.erb_spec.rb b/spec/views/calentries/edit.html.erb_spec.rb new file mode 100644 index 0000000..72b00fd --- /dev/null +++ b/spec/views/calentries/edit.html.erb_spec.rb @@ -0,0 +1,20 @@ +require 'spec_helper' + +describe "calentries/edit" do + before(:each) do + @calentry = assign(:calentry, stub_model(Calentry, + :summary => "MyString", + :typ => 1 + )) + end + + it "renders the edit calentry form" do + render + + # Run the generator again with the --webrat flag if you want to use webrat matchers + assert_select "form[action=?][method=?]", calentry_path(@calentry), "post" do + assert_select "input#calentry_summary[name=?]", "calentry[summary]" + assert_select "input#calentry_typ[name=?]", "calentry[typ]" + end + end +end diff --git a/spec/views/calentries/index.html.erb_spec.rb b/spec/views/calentries/index.html.erb_spec.rb new file mode 100644 index 0000000..cd488a9 --- /dev/null +++ b/spec/views/calentries/index.html.erb_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' + +describe "calentries/index" do + before(:each) do + assign(:calentries, [ + stub_model(Calentry, + :summary => "Summary", + :typ => 1 + ), + stub_model(Calentry, + :summary => "Summary", + :typ => 1 + ) + ]) + end + + it "renders a list of calentries" do + render + # Run the generator again with the --webrat flag if you want to use webrat matchers + assert_select "tr>td", :text => "Summary".to_s, :count => 2 + assert_select "tr>td", :text => 1.to_s, :count => 2 + end +end diff --git a/spec/views/calentries/new.html.erb_spec.rb b/spec/views/calentries/new.html.erb_spec.rb new file mode 100644 index 0000000..32e477b --- /dev/null +++ b/spec/views/calentries/new.html.erb_spec.rb @@ -0,0 +1,20 @@ +require 'spec_helper' + +describe "calentries/new" do + before(:each) do + assign(:calentry, stub_model(Calentry, + :summary => "MyString", + :typ => 1 + ).as_new_record) + end + + it "renders new calentry form" do + render + + # Run the generator again with the --webrat flag if you want to use webrat matchers + assert_select "form[action=?][method=?]", calentries_path, "post" do + assert_select "input#calentry_summary[name=?]", "calentry[summary]" + assert_select "input#calentry_typ[name=?]", "calentry[typ]" + end + end +end diff --git a/spec/views/calentries/show.html.erb_spec.rb b/spec/views/calentries/show.html.erb_spec.rb new file mode 100644 index 0000000..588baec --- /dev/null +++ b/spec/views/calentries/show.html.erb_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' + +describe "calentries/show" do + before(:each) do + @calentry = assign(:calentry, stub_model(Calentry, + :summary => "Summary", + :typ => 1 + )) + end + + it "renders attributes in
" do + render + # Run the generator again with the --webrat flag if you want to use webrat matchers + rendered.should match(/Summary/) + rendered.should match(/1/) + end +end