diff --git a/Gemfile b/Gemfile index ec3165b..ac45d67 100755 --- a/Gemfile +++ b/Gemfile @@ -72,8 +72,9 @@ gem 'paperclip' ,'~>3.4.0' gem 'git' gem 'haml' -#gem 'RedCloth' -#gem 'gollum' +gem 'RedCloth' +gem 'wikicloth' +gem 'gollum-lib' gem 'awesome_nested_set' gem 'annotate', ">=2.5.0" gem 'carrierwave', "~>0.9.0" diff --git a/Gemfile.lock b/Gemfile.lock index 5267261..47b8928 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,6 +9,7 @@ GIT GEM remote: https://rubygems.org/ specs: + RedCloth (4.2.9) actionmailer (3.2.13) actionpack (= 3.2.13) mail (~> 2.5.3) @@ -53,6 +54,7 @@ GEM activemodel (>= 3.2.0) activesupport (>= 3.2.0) json (>= 1.7) + charlock_holmes (0.6.9.4) climate_control (0.0.3) activesupport (>= 3.0) cocaine (0.5.3) @@ -73,6 +75,7 @@ GEM erubis (2.7.0) execjs (1.4.0) multi_json (~> 1.0) + expression_parser (0.9.0) factory_girl (4.3.0) activesupport (>= 3.0.0) factory_girl_rails (4.3.0) @@ -87,12 +90,25 @@ GEM formtastic-bootstrap (2.1.3) formtastic (~> 2.2) git (1.2.6) + github-markup (0.7.5) + gitlab-grit (2.6.0) + charlock_holmes (~> 0.6.9) + diff-lcs (~> 1.1) + mime-types (~> 1.15) + posix-spawn (~> 0.3.6) globalize (3.0.4) activemodel (>= 3.0.0, < 4.0.0) activerecord (>= 3.0.0, < 4.0.0) globalize-versioning (0.1.0.alpha.1) globalize (>= 3, < 5) paper_trail (~> 3.0.0) + gollum-lib (2.0.0) + github-markup (>= 0.7.5, < 1.0.0) + gitlab-grit (= 2.6.0) + nokogiri (~> 1.6.0) + rouge (~> 1.3.1) + sanitize (~> 2.0.6) + stringex (~> 2.1.0) haml (4.0.5) tilt hashie (2.0.5) @@ -150,6 +166,7 @@ GEM cocaine (~> 0.5.0) mime-types polyglot (0.3.3) + posix-spawn (0.3.8) pyu-ruby-sasl (0.0.3.3) rack (1.4.5) rack-cache (1.2) @@ -177,8 +194,10 @@ GEM rdoc (3.12.2) json (~> 1.4) ref (1.0.5) + rinku (1.7.3) rmagick (2.13.2) rolify (3.2.0) + rouge (1.3.4) rspec-core (2.14.7) rspec-expectations (2.14.4) diff-lcs (>= 1.1.3, < 2.0) @@ -208,6 +227,7 @@ GEM rack (~> 1.0) tilt (~> 1.1, != 1.3.0) sqlite3 (1.3.8) + stringex (2.1.2) themes_for_rails (0.5.1) rails (>= 3.0.0) therubyracer (0.12.0) @@ -226,11 +246,17 @@ GEM json (>= 1.8.0) warden (1.2.3) rack (>= 1.0) + webrick (1.3.1) + wikicloth (0.8.1) + builder + expression_parser + rinku PLATFORMS ruby DEPENDENCIES + RedCloth annotate (>= 2.5.0) awesome_nested_set bootstrap-addons-rails @@ -247,6 +273,7 @@ DEPENDENCIES git globalize (~> 3.0.4) globalize-versioning + gollum-lib haml jquery-fileupload-rails jquery-rails @@ -271,3 +298,5 @@ DEPENDENCIES therubyracer tinymce-rails (~> 3.5.8) uglifier (>= 1.0.3) + webrick (= 1.3.1) + wikicloth diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index cdd3a1f..1691fd0 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -18,7 +18,7 @@ def get_theme params[:theme] else -"2003" +"blue1" end end def default_url_options diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 4a37fb1..59ea3df 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -46,19 +46,29 @@ class AttachmentsController < ApplicationController # POST /attachments.json def create @attachment = Attachment.new(params[:attachment]) - @thema = Thema.find(params[:thema_id]) - @attachment.thema_id = @thema.id - @action="create" - logger.info "#{@attachment.inspect}" + @thema = Thema.find_by_id(params[:thema_id]) + # logger.info "gg" + @attachment.thema = @thema + @attachment.name=@attachment.datei.filename + @action="create" + + + # logger.info "sdf" respond_to do |format| - if @attachment.save - format.html { redirect_to @thema, notice: 'Attachment was successfully created.' } - format.json { render json: @thema, status: :created, location: @thema } - format.js { } + if @attachment.save + format.html { + render :json => [@attachment.to_jq_upload].to_json, + :content_type => 'text/html', + :layout => false + } + + # format.html { redirect_to @thema, notice: 'Attachment was successfully created.' } + format.json { render json: {files: [@attachment.to_jq_upload]}, status: :created, location: [@thema, @attachment]} + else format.html { render action: "new" } format.json { render json: @attachment.errors, status: :unprocessable_entity } - format.js { render action: "new.js.erb"} + end end end diff --git a/app/controllers/fetprofiles_controller.rb b/app/controllers/fetprofiles_controller.rb index ad61588..83af41c 100644 --- a/app/controllers/fetprofiles_controller.rb +++ b/app/controllers/fetprofiles_controller.rb @@ -12,9 +12,12 @@ class FetprofilesController < ApplicationController @gremientabs = Gremium.tabs respond_to do |format| format.html # index.html.erb - format.json { render json: @fetprofiles } - end + end end + def internlist + @fetprofiles = Fetprofile.order(:vorname,:nachname) + end + # GET /fetprofiles/1 # GET /fetprofiles/1.json diff --git a/app/controllers/gremien_controller.rb b/app/controllers/gremien_controller.rb index 497163f..3aec4da 100644 --- a/app/controllers/gremien_controller.rb +++ b/app/controllers/gremien_controller.rb @@ -7,6 +7,8 @@ class GremienController < ApplicationController @gremien = Gremium.all @gremientabs=Gremium.tabs @toolbar_elements << {:text=>I18n.t('gremium.new'),:path=>new_gremium_path() ,:icon=>:plus} if can? :new, Gremium + @toolbar_elements << {:text=>I18n.t('profile.new'),:path=>new_fetprofile_path() ,:icon=>:plus} if can? :new, Fetprofile + respond_to do |format| format.html # index.html.erb format.json { render json: @gremien } diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index ba318ee..2aa11d6 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -12,6 +12,7 @@ class HomeController < ApplicationController def intern authorize! :seeintern, User @neuigkeiten = Neuigkeit.intern.recent + @themengruppen=Themengruppe.intern end def startdev render 'setup_fetsite_dev' diff --git a/app/controllers/rubriken_controller.rb b/app/controllers/rubriken_controller.rb index 436b990..7ec78a9 100755 --- a/app/controllers/rubriken_controller.rb +++ b/app/controllers/rubriken_controller.rb @@ -8,7 +8,7 @@ class RubrikenController < ApplicationController @rubriken = Rubrik.where(:public=>true) end @neuigkeiten = @rubriken.collect(&:neuigkeiten).map(&:recent).flatten - @calentries= @rubriken.collect(&:calendar).collect(&:calentries).flatten + @calentries= @rubriken.collect(&:calentries).flatten end def intern diff --git a/app/controllers/themen_controller.rb b/app/controllers/themen_controller.rb index 3a95e58..a4fbea3 100644 --- a/app/controllers/themen_controller.rb +++ b/app/controllers/themen_controller.rb @@ -32,6 +32,9 @@ class ThemenController < ApplicationController end def verwalten @thema = Thema.find(params[:id]) + @attachment=Attachment.new + + @fragen=@thema.fragen @toolbar_elements = [{:icon=>:pencil, :hicon=>'icon-pencil', :text=>"Verwalten", :path=>verwalten_thema_path(@thema)}] @@ -54,6 +57,10 @@ class ThemenController < ApplicationController # GET /themen/1/edit def edit @thema = Thema.find(params[:id]) + unless ( @thema.wikiname.nil? || @thema.wikiname.empty? ) + redirect_to edit_wiki_path(Wiki.find(@thema.id)) + return + end respond_to do |format| format.html format.js @@ -88,6 +95,7 @@ class ThemenController < ApplicationController def attachments @thema = Thema.find(params[:id]) @attachments=@thema.attachments + @attachment=Attachment.new respond_to do |format| format.js end diff --git a/app/controllers/themengruppen_controller.rb b/app/controllers/themengruppen_controller.rb index f639b42..ce8a741 100644 --- a/app/controllers/themengruppen_controller.rb +++ b/app/controllers/themengruppen_controller.rb @@ -24,10 +24,7 @@ class ThemengruppenController < ApplicationController @themen = @themengruppe.themen.order(:priority).reverse @toolbar_elements = [] - @toolbar_elements << {:icon=>:plus, :hicon=>'icon-plus-sign', :text=>I18n.t('thema.add'), :path=>new_themengruppe_thema_path(@themengruppe)} if can? :new, Themengruppe - @toolbar_elements << {:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('themengruppe.edit'), :path=>edit_themengruppe_path(@themengruppe)} if can? :edit, @themengruppe @toolbar_elements << {:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t("themengruppe.manage"), :path=>themengruppe_verwalten_path(@themengruppe)} if can? :edit, @themengruppe - @toolbar_elements << {:hicon=>'icon-remove-circle',:text=>I18n.t('themengruppe.remove'), :path=>themengruppe_path(@themengruppe), :method=>:delete,:confirm=>I18n.t('themengruppe.sure')} if can? :delete, @themengruppe respond_to do |format| format.html # show.html.erb @@ -52,10 +49,18 @@ class ThemengruppenController < ApplicationController end def verwalten_all @themengruppen =Themengruppe.order(:priority).reverse - end + @toolbar_elements = [{:icon=>:plus, :hicon=>'icon-plus-sign', :text=>I18n.t('themengruppe.new'), :path=>new_themengruppe_path()}] + + end def verwalten @themengruppe = Themengruppe.find(params[:themengruppe_id]) @themen = @themengruppe.themen.order(:priority).reverse + + @toolbar_elements =[] + @toolbar_elements << {:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('themengruppe.edit'), :path=>edit_themengruppe_path(@themengruppe)} if can? :edit, @themengruppe + @toolbar_elements << {:icon=>:plus, :hicon=>'icon-plus-sign', :text=>I18n.t('thema.add'), :path=>new_themengruppe_thema_path(@themengruppe)} if can? :new, Themengruppe + @toolbar_elements << {:hicon=>'icon-remove-circle',:text=>I18n.t('themengruppe.remove'), :path=>themengruppe_path(@themengruppe), :method=>:delete,:confirm=>I18n.t('themengruppe.sure')} if can? :delete, @themengruppe + end def sort_themengruppen diff --git a/app/controllers/wikis_controller.rb b/app/controllers/wikis_controller.rb new file mode 100644 index 0000000..a61be11 --- /dev/null +++ b/app/controllers/wikis_controller.rb @@ -0,0 +1,46 @@ +class WikisController < ApplicationController + load_and_authorize_resource + + def show + @wiki = Wiki.find(params[:id]) + @fragen = @wiki.fragen + @toolbar_elements = [{:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('wiki.edit'), :path=>verwalten_wiki_path(@wiki)}] + end + + def wiki + @wiki = Wiki.find_or_init(params[:name]) + @fragen = @wiki.fragen + @toolbar_elements = [] +# @toolbar_elements = [{:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('wiki.edit'), :path=>verwalten_wiki_path(@wiki)}] + + redirect_to wiki_path(@wiki) + end + + + def edit + @wiki = Wiki.find(params[:id]) + respond_to do |format| + format.html + format.js + end + + end + + def update + @wiki = Wiki.find(params[:id]) + @themen = @wiki.themengruppe.themen.order(:priority).reverse + @wiki.raw_data=params[:wiki][:raw_data] + respond_to do |format| + if @wiki.update_attributes(params[:wiki]) + format.html { redirect_to verwalten_thema_path(@wiki), notice: 'Thema was successfully updated.' } + format.json { head :no_content } + format.js + else + format.html { render action: "edit" } + format.json { render json: @wiki.errors, status: :unprocessable_entity } + format.js { render action: "edit" } + end + end + + end +end diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 1efccd6..c61214f 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -12,9 +12,22 @@ class Attachment < ActiveRecord::Base has_paper_trail - attr_accessible :name, :datei + attr_accessible :name, :datei, :datei_cache belongs_to :thema mount_uploader :datei, AttachmentUploader validates :thema, :presence => true validates :name, :presence => true + + def to_jq_upload + { + "id" => read_attribute(:id), + "title" => read_attribute(:title), + "description" => read_attribute(:desc), + "name" => read_attribute(:title), + "size" => datei.size, + "url" => datei.url, + "thumbnail_url" => datei.thumb.url, + "delete_type" => "DELETE" + } + end end diff --git a/app/models/calentry.rb b/app/models/calentry.rb index f7f0699..8ee967e 100644 --- a/app/models/calentry.rb +++ b/app/models/calentry.rb @@ -32,7 +32,7 @@ class Calentry < ActiveRecord::Base resourcify def get_public - self.public = (self.try(:object).nil?)? (self.calendar.try(:public)) : object.try(:public) + self.public = (self.try(:object).nil?)? (self.calendar.try(:public?)) : object.try(:public?) true end def start_time diff --git a/app/models/fetprofile.rb b/app/models/fetprofile.rb index 787c175..a73c3ce 100644 --- a/app/models/fetprofile.rb +++ b/app/models/fetprofile.rb @@ -15,19 +15,27 @@ # class Fetprofile < ActiveRecord::Base - attr_accessible :active, :desc, :fetmailalias, :nachname, :picture, :short, :vorname, :memberships_attributes, :remove_picture, :picture_cache + attr_accessible :active, :desc, :fetmailalias, :nachname, :picture, :short, :vorname, :memberships_attributes, :remove_picture, :picture_cache, :plz, :street, :city, :instant,:skype, :telnr, :hdynr, :birth_day, :birth_month, :birth_year,:geschlecht has_many :memberships, dependent: :delete_all has_many :gremien, :through=> :membership mount_uploader :picture, PictureUploader has_paper_trail -validates :desc, :presence=>true + validates :desc, :presence=>true validates :nachname, length:{minimum: 3},:presence=>true validates :vorname, length:{minimum: 3},:presence=>true + validate :validate_birthday + GESCHLECHT={0=>"gendered", 1=>"maennlich", 2=>"weiblich"} has_many :users scope :search, ->(query) {where("nachname like ? or vorname like ? or short like ?", "%#{query}%", "%#{query}%", "%#{query}%")} accepts_nested_attributes_for :memberships, :reject_if=>lambda{|a| a[:typ].blank?|| a[:start].blank? ||a[:gremium_id].blank?}, :allow_destroy=>true has_many :nlinks, as: :link + def validate_birthday + unless Date.valid_date?(birth_year, birth_month, birth_day) + errors.add(:birth_month, "Invalides Datum") + errors.add(:birth_day, "Invalides Datum") + end + end def title self.name @@ -39,4 +47,15 @@ validates :desc, :presence=>true def fetmail (fetmailalias.nil? || fetmailalias.empty?) ? short.to_s + "@fet.at" : fetmailalias.to_s + "@fet.at" end + def adress + connector= (self.street.nil?||self.street.empty?||(self.city.empty? && self.plz.empty?)) ? '' : ', ' + self.plz.to_s + ' ' + self.city.to_s + connector.to_s + self.street.to_s + end + def birthday + if self.birth_year.nil? || self.birth_year.zero? + Date.new( Date.today.year,self.birth_month,self.birth_day) + else + Date.new( self.birth_year,self.birth_month,self.birth_day) + end + end end diff --git a/app/models/gremium.rb b/app/models/gremium.rb index ea92010..fe5d2d1 100644 --- a/app/models/gremium.rb +++ b/app/models/gremium.rb @@ -14,8 +14,8 @@ class Gremium < ActiveRecord::Base TYPEN={1=>"offiziell", 2=>"offiziell-temporär", 3 => "inoffiziell",4=>"inoffiziell-tempo", 11=> "berufungskommission",12=> "habilitationskommission" } # Kategorien, im Wesentlichen wichtig für Listung oder nicht Listung GESCHLECHT={0=>"saechlich", 1 => "maennlich", 2 => "weiblich"} # Geschlecht des Gremiums zur richtige Deklination - ART2FALL={0=>"des", 1=>"des",2=>"der"} # Artikel 2.Fall abhängig vom Geschlecht - ART4FALL={0=>"das", 1=>"den",2=>"die"} # Artikel 2.Fall abhängig vom Geschlecht + ART2FALL={0=>"des", 1=>"des",2=>"der"} # Artikel 2.Fall abhängig vom Geschlecht + ART4FALL={0=>"das", 1=>"den",2=>"die"} # Artikel 2.Fall abhängig vom Geschlecht FILTER={11=>I18n.t("gremium.filter.berufung.title"),12=>I18n.t("gremium.filter.habil.title")} TEXT={11=>I18n.t("gremium.filter.berufung.text"),12=>I18n.t("gremium.filter.habil.text")} diff --git a/app/models/lva.rb b/app/models/lva.rb index 5a0f5d5..4c80b04 100755 --- a/app/models/lva.rb +++ b/app/models/lva.rb @@ -58,12 +58,14 @@ class Lva < ActiveRecord::Base validates_presence_of :modul # Zugehöriges Modul eingetragen? # (zumindest eines) - + def typ_n + typ=="andere" ? "" : typ + end def title self.name end def full_name - return self.typ + ' ' + self.name + return self.typ_n + ' ' + self.name end def add_semesters # Diese Methode fügt die Instanz automatisch zu allen Studien als "Ohne Semesterempfehlung" (Semester 0) zu, bei denen die Instanz im Studium noch nicht vorkommt. diff --git a/app/models/membership.rb b/app/models/membership.rb index 668dbce..272980b 100644 --- a/app/models/membership.rb +++ b/app/models/membership.rb @@ -14,6 +14,7 @@ class Membership < ActiveRecord::Base TYPEN={-2=>"VorsitzendeR", -1=>"stv VorsitzendeR", 0=>"2. stv VorsitzendeR", 1=>"Mitglied",2=> "Ersatzmitglied",3=>"VerantwortlicheR"} + TYPEN_g={0=>TYPEN, 1=>{ -2=>"Vorsitzender", -1=>"stv Vorsitzender", 0=>"2. stv Vorsitzender", 1=>"Mitglied",2=> "Ersatzmitglied",3=>"Verantwortlicher"},2=>{-2=>"Vorsitzende", -1=>"stv Vorsitzende", 0=>"2. stv Vorsitzende", 1=>"Mitglied",2=> "Ersatzmitglied",3=>"Verantwortliche"}} attr_accessible :fetprofile_id, :gremium_id, :start, :stop, :typ belongs_to :fetprofile belongs_to :gremium diff --git a/app/models/modul.rb b/app/models/modul.rb index 3b46cd9..1c3bb42 100755 --- a/app/models/modul.rb +++ b/app/models/modul.rb @@ -12,7 +12,7 @@ # class Modul < ActiveRecord::Base - attr_accessible :desc,:name, :depend, :studium_id, :modulgruppen + attr_accessible :desc,:name, :depend, :studium_id, :modulgruppen, :modulgruppe_ids has_and_belongs_to_many :lvas , :uniq=>true has_and_belongs_to_many :modulgruppen diff --git a/app/models/thema.rb b/app/models/thema.rb index c32149c..156a3f5 100644 --- a/app/models/thema.rb +++ b/app/models/thema.rb @@ -22,7 +22,9 @@ class Thema < ActiveRecord::Base validates :text, :presence => true scope :search, ->(query) {where("text like ? or title like ?", "%#{query}%", "%#{query}%")} translates :title,:text, :versioning =>true, :fallbacks_for_empty_translations => true - + def is_wiki? + wikiname.nil? || wikiname.empty? + end def text_first_words md = /

(?[^\<\>]*)/.match Sanitize.clean(self.text,:elements=>['p']) words=md[:text].split(" ") unless md.nil? diff --git a/app/models/themengruppe.rb b/app/models/themengruppe.rb index ca42007..f4f206e 100644 --- a/app/models/themengruppe.rb +++ b/app/models/themengruppe.rb @@ -10,7 +10,7 @@ class Themengruppe < ActiveRecord::Base WORD_COUNT = 50 - attr_accessible :text, :title, :picture, :priority + attr_accessible :text, :title, :picture, :priority, :public has_many :themen, class_name: 'Thema' has_many :fragen, through: :themen @@ -20,4 +20,17 @@ class Themengruppe < ActiveRecord::Base validates :text, :presence => true translates :title,:text, :versioning =>true, :fallbacks_for_empty_translations => true + + scope :intern,-> {where(:public=>false)} + + def self.find_wiki_default + where(:wiki_default=>true).first + end + + def make_wiki_default + Themengruppe.where(:wiki_default=>:true).update_all(:wiki_default=>:false) + self.wiki_default=true; + self.save; + end + end diff --git a/app/models/wiki.rb b/app/models/wiki.rb new file mode 100644 index 0000000..23cd374 --- /dev/null +++ b/app/models/wiki.rb @@ -0,0 +1,73 @@ +class Wiki < Thema + validates :wikiname, :uniqueness=>true, :presence=>true + after_initialize :load_wiki + attr_accessible :wikiname, :wikiformat, :hidelink, :raw_data + WIKIFORMATS={nil=> :textile, 0 =>:textile, 1=> :mediawiki} + + def self.find_or_init(name) + w = Wiki.where(:wikiname=>name).first + page = is_file_availaible(name) + if w.nil? + unless page.nil? + w=Wiki.new(:wikiname=>name, :title=>name, :wikiformat=>Wiki::WIKIFORMATS.invert[page.format], :hidelink=>true) + else + w=Wiki.new(:wikiname=>name, :title=>name, :wikiformat=>0, :hidelink=>true) + wiki = Gollum::Wiki.new("../wiki.git", :base_path => "/wiki") + page=wiki.write_page(name, :textile, "ioi", self.commit) + w.reload_page + end + + w.themengruppe = Themengruppe.find_wiki_default + w.raw_data="Neues Wiki" + w.save + end + w + end + + def raw_data + self.page.raw_data + end + + def raw_data=(data) + self.get_page(self.wikiname) + self.wiki.update_page(self.page, self.wikiname, Wiki::WIKIFORMATS[self.wikiformat], data, self.commit) + self.text=self.page.formatted_data + + end + + def page + self.get_page(wikiname) if @page.nil? + @page + end + + def wiki + @wiki + end + def reload_page + self.get_page(self.wikiname) + end + protected + + + def self.is_file_availaible(name) + wiki = Gollum::Wiki.new("../wiki.git", :base_path => "/wiki") + wiki.page(name) + end + + def load_wiki + @wiki = Gollum::Wiki.new("../wiki.git", :base_path => "/wiki") + end + + def get_page(name) + @page= @wiki.page(name) + @page=self.wiki.write_page(self.wikiname, Wiki::WIKIFORMATS[self.wikiformat]," ",self.commit) if @page.nil? + @page + end + def commit + {message: "RailsUpdate", name:"SomeUser", email: "ttt@t"} + end + + def self.commit + {message: "RailsUpdate", name:"SomeUser", email: "ttt@t"} + end +end diff --git a/app/uploaders/attachment_uploader.rb b/app/uploaders/attachment_uploader.rb index cba26e4..2973828 100644 --- a/app/uploaders/attachment_uploader.rb +++ b/app/uploaders/attachment_uploader.rb @@ -6,6 +6,9 @@ class AttachmentUploader < CarrierWave::Uploader::Base include CarrierWave::RMagick # include CarrierWave::RMagick # include CarrierWave::MiniMagick +def root + Rails.root.join 'public/' +end # Choose what kind of storage to use for this uploader: storage :file @@ -20,6 +23,9 @@ class AttachmentUploader < CarrierWave::Uploader::Base version :thumb do process :resize_to_fill => [64, 64] end + version :thumb_small do + process :resize_to_fill => [32, 32] + end # Provide a default URL as a default if there hasn't been a file uploaded: # def default_url diff --git a/app/views/attachments/_attachment.html.erb b/app/views/attachments/_attachment.html.erb index 1fc66d3..0045f70 100644 --- a/app/views/attachments/_attachment.html.erb +++ b/app/views/attachments/_attachment.html.erb @@ -1,9 +1,9 @@ <% data_ext = attachment.datei.file.extension.downcase %> - <%= attachment.name %>
+ <% if (!["jpg","png","jpeg"].find_index(data_ext).nil?) %> <%= image_tag attachment.datei.thumb.url %> <% else %> <%= image_tag "pdf-logo.jpg" %> <% end %> - + <%= attachment.name %> diff --git a/app/views/attachments/_form_bulk.html.erb b/app/views/attachments/_form_bulk.html.erb new file mode 100644 index 0000000..b8c8616 --- /dev/null +++ b/app/views/attachments/_form_bulk.html.erb @@ -0,0 +1,143 @@ + +

+ <%= semantic_form_for [@thema,@attachment], :remote=>true, :html => { :multipart => true, :id => "fileupload" } do |f| %> + +
+ +
+
+ + + + Add files... + <%= f.file_field :datei, :multiple=>true %> + <% f.input :thema %> + + + + + +
+
+ +
+
+
+
+
+
+ +
+
+ + +
+ <% end %> + +
+ + + + + + + + diff --git a/app/views/fetprofiles/_form.html.erb b/app/views/fetprofiles/_form.html.erb index 8143c08..1467d1f 100644 --- a/app/views/fetprofiles/_form.html.erb +++ b/app/views/fetprofiles/_form.html.erb @@ -15,7 +15,7 @@
-
<%= f.input :active %>
+
<%= f.input :active %> <%= f.input :geschlecht,:as=>:select, :collection=>Fetprofile::GESCHLECHT.invert %>
<%= image_tag(@fetprofile.picture.thumb.url) unless @fetprofile.picture.nil? %> <%= f.file_field :picture %> @@ -28,24 +28,35 @@
<%= f.input :fetmailalias %>
-<% @memberships.each do |m| %> +
+
+Adresse: - <%= f.semantic_fields_for :memberships, m do |membership| %> - -
- - -
<%= membership.input :start, :as=>:datepicker, :prepend=>"von",:label=>false%>
-
<%= membership.input :stop, :as=>:datepicker,:label=>false, :prepend =>"bis" %>
-
<%= membership.input :typ ,:as=>:select, :collection=>Membership::TYPEN.invert, :label=>false %>
-
<%= membership.input :gremium, :label=>false %> +<%=f.input :street %> +<%=f.input :plz %> +<%=f.input :city %> +KOntakt: +<%=f.input :instant %> +<%=f.input :skype %> +<%=f.input :telnr %> +<%=f.input :hdynr %>
-
<%= membership.check_box :_destroy %> <%= I18n.t 'common.delete' %>
- -
- <% end %> - <% end %> <% end %> +
+Geburtstag: +<%=f.input :birth_day %> +<%=f.input :birth_month %> +<%=f.input :birth_year %> +
+ +
+
+<% @memberships.each do |m| %> +<%= render partial:"membership_fields", object: m , locals: {:f=>f} %> +<% end %> +
+ +<% end %>
<%= f.actions do %> diff --git a/app/views/fetprofiles/_interninfo.html.erb b/app/views/fetprofiles/_interninfo.html.erb new file mode 100644 index 0000000..889ab47 --- /dev/null +++ b/app/views/fetprofiles/_interninfo.html.erb @@ -0,0 +1,16 @@ +

+Geburtstag <%= %> +

+

+ Adresse: + <%= interninfo.plz %> + <%= interninfo.city %>, + <%= interninfo.street %> +

+

+ <%= raw("Telefon: ")+ interninfo.telnr + "
" unless interninfo.telnr.empty?%> + <%= raw("Handy: ") +interninfo.hdynr unless interninfo.hdynr.empty? %>
+<%= raw("Skype: ") +interninfo.skype unless interninfo.skype.empty? %>
+<%= raw("Instant Messaging: ") +interninfo.instant unless interninfo.instant.empty? %>
+ +

diff --git a/app/views/fetprofiles/_internrow.html.erb b/app/views/fetprofiles/_internrow.html.erb new file mode 100644 index 0000000..63fbb75 --- /dev/null +++ b/app/views/fetprofiles/_internrow.html.erb @@ -0,0 +1,12 @@ + + <%= link_to internrow.name, internrow %> + + <%= internrow.adress %> + + <%= raw("Telefon: ")+ internrow.telnr + "
" unless internrow.telnr.nil? || internrow.telnr.empty?%> + <%= raw("Handy: ") +internrow.hdynr + raw("
") unless internrow.hdynr.nil? || internrow.hdynr.empty? %> +<%= raw("Skype: ") +internrow.skype + raw("
") unless internrow.skype.nil? || internrow.skype.empty? %> +<%= raw("Instant Messaging: ") +internrow.instant + raw("
") unless internrow.instant.nil? || internrow.instant.empty? %> + +<%= internrow.fetmail %> + diff --git a/app/views/fetprofiles/_membership_fields.html.erb b/app/views/fetprofiles/_membership_fields.html.erb new file mode 100644 index 0000000..957347e --- /dev/null +++ b/app/views/fetprofiles/_membership_fields.html.erb @@ -0,0 +1,13 @@ +<%= f.semantic_fields_for :memberships, membership_fields do |membership| %> +
+<%= membership.input :start, :as=>:datepicker, :prepend=>"von",:label=>false , :input_html => { :style => "width:6em"} %> + + <%= membership.input :stop, :as=>:datepicker,:label=>false, :prepend =>"bis" , :input_html => { :style => "width:6em"}%> + +<%= membership.input :typ ,:as=>:select, :collection=>Membership::TYPEN.invert, :label=>false , :input_html => { :style => "width:12em" }%> + +<%= membership.input :gremium, :label=>false %> + +<%= membership.check_box :_destroy %> <%= I18n.t 'common.delete' %>
+ +<% end %> diff --git a/app/views/fetprofiles/internlist.html.erb b/app/views/fetprofiles/internlist.html.erb new file mode 100644 index 0000000..5d8f566 --- /dev/null +++ b/app/views/fetprofiles/internlist.html.erb @@ -0,0 +1,5 @@ + +<% @fetprofiles.each do |item| %> +<%= render partial: "internrow", object: item %> +<% end %> +
diff --git a/app/views/fetprofiles/show.html.erb b/app/views/fetprofiles/show.html.erb index ded2659..b62caae 100644 --- a/app/views/fetprofiles/show.html.erb +++ b/app/views/fetprofiles/show.html.erb @@ -10,10 +10,15 @@

<%= @fetprofile.fetmail %>

-

+ respond_to do |format| + format.html # index.html.erb + format.json { render json: @fetprofiles } + end + +

<%= @fetprofile.desc %>

- + <%= render partial: "interninfo", object: @fetprofile if can?(:seeintern, @fetprofile) %>
    <% @memberships.each do |m| %>
  • diff --git a/app/views/fragen/_form.html.erb b/app/views/fragen/_form.html.erb index ce19bc5..a445ffe 100644 --- a/app/views/fragen/_form.html.erb +++ b/app/views/fragen/_form.html.erb @@ -10,3 +10,5 @@ <%= f.action :submit, :as => :input %> <% end %> <% end %> + + <%= tinymce %> diff --git a/app/views/fragen/_rform.html.erb b/app/views/fragen/_rform.html.erb index a3780d1..923744a 100644 --- a/app/views/fragen/_rform.html.erb +++ b/app/views/fragen/_rform.html.erb @@ -10,3 +10,4 @@ <%= f.action :submit, :as => :input %> <% end %> <% end %> + <%= tinymce %> diff --git a/app/views/gremien/_form.html.erb b/app/views/gremien/_form.html.erb index d253575..9537158 100644 --- a/app/views/gremien/_form.html.erb +++ b/app/views/gremien/_form.html.erb @@ -7,35 +7,29 @@ <%= f.input :thema, :as=> :select, :collection => Thema.all %> - <% f.inputs :for => :memberships, :objects=>@memberships do |membership,i| %> -
    -
    -
    <%= membership.input :start, :as=>:datepicker, :prepend=>"von",:label=>false%>
    -
    <%= membership.input :stop, :as=>:datepicker,:label=>false, :prepend =>"bis" %>
    -
    <%= membership.input :typ ,:as=>:select, :collection=>Membership::TYPEN.invert, :label=>false %>
    -
    <%= membership.input :fetprofile, :as=>:select, :label=>false %>
    - - -
    - <% end %> - - -<% @memberships.each do |m| %> + <% @memberships.each do |m| %> <%= f.semantic_fields_for :memberships, m do |memberships_attributes| %>
    -
    <%= memberships_attributes.input :start, :as=>:datepicker, :prepend=>"von",:label=>false%>
    -
    <%= memberships_attributes.input :stop, :as=>:datepicker,:label=>false, :prepend =>"bis" %>
    -
    <%= memberships_attributes.input :typ ,:as=>:select, :collection=>Membership::TYPEN.invert, :label=>false %>
    -
    <%= memberships_attributes.input :fetprofile, :as=>:select, :label=>false %>
    - - +
    + + + + + + +
    <%= memberships_attributes.input :start, :as=>:datepicker, :prepend=>"von",:label=>false , :input_html => { :style => "width:6em" } ,:value=>Proc.new { |c| I18n.l(c) }%> + + <%= memberships_attributes.input :stop, :as=>:datepicker,:label=>false, :prepend =>"bis" , :input_html => { :style => "width:6em"},:value_method=>Proc.new { |c| I18n.l(c) }%> + + <%= memberships_attributes.input :typ ,:as=>:select, :collection=>Membership::TYPEN.invert, :label=>false, :input_html => { :style => "width:12em" } %> + <%= memberships_attributes.input :fetprofile, :as=>:select, :label=>false %>
    +
    + <% end %> + <% end %> <% end %> -<% end %> - - <% end %> <%= f.actions do %> <%= f.action :submit, :as => :input %> @@ -43,3 +37,9 @@ <% end %> <%= tinymce %> + + + + + + diff --git a/app/views/gremien/verwalten.html.erb b/app/views/gremien/verwalten.html.erb index 38a339e..27b7113 100644 --- a/app/views/gremien/verwalten.html.erb +++ b/app/views/gremien/verwalten.html.erb @@ -1,4 +1,5 @@

    Listing gremien

    +<%= render 'layouts/pretty_toolbar' %>
    <% @gremien.each do |gremium| %>
    @@ -38,7 +39,7 @@
    -<%= render 'layouts/pretty_toolbar' %> + diff --git a/app/views/home/intern.html.erb b/app/views/home/intern.html.erb index b419c02..ac474c8 100644 --- a/app/views/home/intern.html.erb +++ b/app/views/home/intern.html.erb @@ -1,10 +1,31 @@

    FET Intern NEU

    -

    Neuigkeiten

    - +
    +
    +
    + <%= link_to "Adressliste", internlist_fetprofiles_path %> + <%= link_to "Internes Nachschlagewerk" %> + + + +
    +
    +

    Neuigkeiten

    + +
    +
    +

    diff --git a/app/views/lvas/_lva.html.erb b/app/views/lvas/_lva.html.erb index a49bb55..16ff66f 100755 --- a/app/views/lvas/_lva.html.erb +++ b/app/views/lvas/_lva.html.erb @@ -1,6 +1,6 @@

    <%= notice %>

    -

    <%=lva.typ.to_s + ' ' + lva.name %>

    +

    <%= lva.typ_n.to_s + ' ' + lva.name %>

    Prüfungsinformation

    <%= lva.pruefungsinformation.to_s.html_safe %> diff --git a/app/views/lvas/show.html.erb b/app/views/lvas/show.html.erb index d5bb9cb..a7b8818 100755 --- a/app/views/lvas/show.html.erb +++ b/app/views/lvas/show.html.erb @@ -3,11 +3,11 @@

    <%= notice %>

    -

    <%=@lva.typ.to_s + ' ' + @lva.name %>

    +

    <%= @lva.full_name %>

    Prüfungsinformation

    - <%= @lva.pruefungsinformation.html_safe %> + <%= @lva.pruefungsinformation.to_s.html_safe %>

    Lernaufwand

    diff --git a/app/views/memberships/_membership.html.erb b/app/views/memberships/_membership.html.erb index f6b8679..e2689e9 100644 --- a/app/views/memberships/_membership.html.erb +++ b/app/views/memberships/_membership.html.erb @@ -2,5 +2,5 @@ <%= membership.stop.nil? ? "seit " : "von " %> <%=membership.start.to_s %> <%= " bis "+membership.stop.to_s unless membership.stop.nil? %> -<%= Membership::TYPEN[membership.typ.to_i] %> +<%= Membership::TYPEN_g[membership.fetprofile.geschlecht.to_i][membership.typ.to_i] %> <%= membership.gremium.fall2 %> diff --git a/app/views/studien/_semesteransicht.html.erb b/app/views/studien/_semesteransicht.html.erb index 416e667..66ed037 100644 --- a/app/views/studien/_semesteransicht.html.erb +++ b/app/views/studien/_semesteransicht.html.erb @@ -15,8 +15,8 @@

    <%= sem.name %>

    -
    <%= link_to I18n.t("lva.addrem"), edit_semester_path(sem), :class=>"btn-small"%> -
    +
    +
    <% sem.lvas.each do |lva| %> diff --git a/app/views/studien/semesteransicht.html.erb b/app/views/studien/semesteransicht.html.erb index 5ea2bde..078f445 100644 --- a/app/views/studien/semesteransicht.html.erb +++ b/app/views/studien/semesteransicht.html.erb @@ -20,16 +20,17 @@ <% end %> <% @studium.semester.each do |sem| %> -
    +
    -

    <%= sem.name %>

    -
    -
    <%= link_to I18n.t("lva.addrem"), edit_semester_path(sem), :class=>"btn-small"%>
    +

    <%= sem.name %>

    +
    +
    +
    <% sem.lvas.each do |lva| %>
    diff --git a/app/views/themen/_attachment_list.html.erb b/app/views/themen/_attachment_list.html.erb index 7b9c0cf..a1c128d 100644 --- a/app/views/themen/_attachment_list.html.erb +++ b/app/views/themen/_attachment_list.html.erb @@ -2,11 +2,17 @@ <% attachment_list.each do |a| %> + <%= link_to a.datei.url do %> <%= render a %> +<% end %> +<% if editor %> <%= link_to "Edit", edit_thema_attachment_path(a.thema,a) %> +<%= link_to "Delete", thema_attachment_path(a.thema,a), method: "DELETE", confirm: "Sure?" %> + +<% end %> <% end %> diff --git a/app/views/themen/_attachment_verwalten.html.erb b/app/views/themen/_attachment_verwalten.html.erb new file mode 100644 index 0000000..8fb67c3 --- /dev/null +++ b/app/views/themen/_attachment_verwalten.html.erb @@ -0,0 +1,3 @@ + +<%= render :partial=>"attachments/form_bulk" %> +<%= render partial: "themen/attachment_list", object:@thema.attachments ,locals: {:editor => true}%> diff --git a/app/views/themen/_form.html.erb b/app/views/themen/_form.html.erb index 08e8b59..6a77d03 100644 --- a/app/views/themen/_form.html.erb +++ b/app/views/themen/_form.html.erb @@ -2,7 +2,7 @@
    -<%= semantic_form_for @thema, :remote=>true do |f| %> +<%= semantic_form_for @thema, :remote=>remote do |f| %> <%= f.inputs do %>
    diff --git a/app/views/themen/_fragen.html.erb b/app/views/themen/_fragen.html.erb index 727a14f..ea30282 100644 --- a/app/views/themen/_fragen.html.erb +++ b/app/views/themen/_fragen.html.erb @@ -6,5 +6,5 @@
    <%= render :partial=>'fragen/rform' %>
    -<% @frage_elements = [{:icon=>:plus, :hicon=>'icon-plus', :text=>I18n.t('frage.add'), :path=>new_frage_path}] %> -<%= render :partial=>'layouts/pretty_toolbar', :object=>@frage_elements %> +<% # @frage_elements = [{:icon=>:plus, :hicon=>'icon-plus', :text=>I18n.t('frage.add'), :path=>new_frage_path}] %> +<% # render :partial=>'layouts/pretty_toolbar', :object=>@frage_elements %> diff --git a/app/views/themen/_small.html.erb b/app/views/themen/_small.html.erb index dfe8095..8c40748 100644 --- a/app/views/themen/_small.html.erb +++ b/app/views/themen/_small.html.erb @@ -1,18 +1,22 @@ - -

    <%= small.title %>

    -
    + +

    <%= small.title %> <%= link_to fa_icon("pencil"), verwalten_thema_path(small) if can? :edit, small %>

    +
    <%= raw(small.text) %>
    -<%= raw("FAQs:") unless small.fragen.empty? %> +<%= raw("FAQs:") unless small.fragen.empty? %>
    <% small.fragen.each do |frage| %>

    - <%= frage.title %>
    -<%= raw(frage.text) %> + <%= frage.title %>
    + <%= raw(frage.text) %>

    -
    <% end %> + +<%= render partial: "themen/attachment_list", object: small.attachments, locals:{editor: false} unless small.attachments.empty? %> +
    + + <% @small_elements = [] @small_elements << {:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('thema.edit'), :path=>small} if can? :edit, small diff --git a/app/views/themen/attachments.js.erb b/app/views/themen/attachments.js.erb index 79f8f32..e1dceb5 100644 --- a/app/views/themen/attachments.js.erb +++ b/app/views/themen/attachments.js.erb @@ -1 +1 @@ -$("#themaview").html("<%= escape_javascript(raw("

    "+I18n.t('thema.show')+"

    ")+render(:partial=>"themen/attachment_list", :object=>@attachments) )%>"); \ No newline at end of file +$("#themaview").html("<%= escape_javascript(raw("

    "+I18n.t('thema.show')+"

    ")+render(:partial=>"themen/attachment_verwalten") )%>"); \ No newline at end of file diff --git a/app/views/themen/edit.html.erb b/app/views/themen/edit.html.erb index de6c7a3..10d69ea 100644 --- a/app/views/themen/edit.html.erb +++ b/app/views/themen/edit.html.erb @@ -1,5 +1,5 @@

    Editing thema

    -<%= render 'form' %> +<%= render 'form' , :locals=>{:remote=>false}, :remote=>false %>

    <%= link_to 'Back', @thema %> diff --git a/app/views/themen/edit.js.erb b/app/views/themen/edit.js.erb index 30ca8ab..7256636 100644 --- a/app/views/themen/edit.js.erb +++ b/app/views/themen/edit.js.erb @@ -1 +1 @@ -$("#themaview").html("<%= escape_javascript(raw("

    "+I18n.t('thema.edit')+"

    ")+render(:partial=>"themen/form") )%>"); +$("#themaview").html("<%= escape_javascript(raw("

    "+I18n.t('thema.edit')+"

    ")+render(:partial=>"themen/form", :locals=>{:remote=>true}) )%>"); diff --git a/app/views/themen/show.html.erb b/app/views/themen/show.html.erb index aa8912a..534a436 100644 --- a/app/views/themen/show.html.erb +++ b/app/views/themen/show.html.erb @@ -5,5 +5,3 @@ <%= render :partial=>'layouts/pretty_toolbar' %> -<%= link_to new_thema_attachment_path(@thema) ,:remote=>true do %> new Attachment <% end %> -<%= render :partial => "themen/select", :object => @thema, :locals=>{:editor => :false} %> diff --git a/app/views/themen/verwalten.html.erb b/app/views/themen/verwalten.html.erb index 70177ca..6b1a1bd 100644 --- a/app/views/themen/verwalten.html.erb +++ b/app/views/themen/verwalten.html.erb @@ -1,6 +1,9 @@

    <%= notice %>

    -

    <%= @thema.title %>

    +
    +
    +
    +

    <%= raw(@thema.text) %>

    @@ -11,16 +14,22 @@ --> <%= render :partial=>'layouts/pretty_toolbar' %> +

    <%= I18n.t('attachment.title')%>:

    +
    +
    +<%= render partial: "attachment_verwalten" %> +<%= render :partial => "themen/select", :object => @thema, :locals=>{:editor => :false} %> + +
    +
    + <%= render :partial=>'themen/fragen' %>
    -

    <%= I18n.t('attachment.title')%>:

    -
    -
    - -<%= link_to new_thema_attachment_path(@thema) ,:remote=>true do %> new Attachment <% end %> -<%= render :partial => "themen/select", :object => @thema, :locals=>{:editor => :false} %> <%= link_to I18n.t('common.back'), themengruppen_path, :class=>:btn %> +
    +
    +
    diff --git a/app/views/themengruppen/_form.html.erb b/app/views/themengruppen/_form.html.erb index e8c5f15..90e9409 100644 --- a/app/views/themengruppen/_form.html.erb +++ b/app/views/themengruppen/_form.html.erb @@ -2,6 +2,7 @@ <%= f.inputs do %> <%= f.input :title %> <%= f.input :priority %> + <%= f.input :public %> <%= f.input :picture, :as => :file %> <%= f.input :text %> diff --git a/app/views/themengruppen/index.html.erb b/app/views/themengruppen/index.html.erb index 2bcb394..40e7649 100644 --- a/app/views/themengruppen/index.html.erb +++ b/app/views/themengruppen/index.html.erb @@ -1,35 +1,28 @@
    -

    <%= link_to "FAQS", faqs_themengruppen_path,class: :btn %>

    - -
    +
    - -<%= render :partial=>'layouts/pretty_toolbar' %> + diff --git a/app/views/themengruppen/show.html.erb b/app/views/themengruppen/show.html.erb index daf766d..141a0ca 100644 --- a/app/views/themengruppen/show.html.erb +++ b/app/views/themengruppen/show.html.erb @@ -1,7 +1,10 @@
    <%= link_to fa_icon("arrow-circle-left 2x")+" Alle Themengruppen", themengruppen_path, :class=>"linkbox" %> <%= link_to fa_icon("question 2x")+" Häufige Fragen", faqs_themengruppen_path(:anchor=>"themengruppe_"+@themengruppe.id.to_s), :class=>"linkbox" %> + <%= render :partial=>'layouts/pretty_toolbar' %> +

    <%= @themengruppe.title %>

    +

    <%= @themengruppe.text %>

    @@ -10,13 +13,8 @@
  • <%= render :partial => 'themen/small', :object => thema %> - tools: - <% - @small_elements2 = [] - @small_elements2 << {:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('common.verwalten'), :path=>verwalten_thema_path(thema)} if can? :edit, thema - %> - <%= render :partial=>'layouts/pretty_toolbar', :object=>@small_elements2 unless @small_elements2.empty? %> +
      <% unless thema.gremium.nil? %> @@ -37,5 +35,4 @@ <% end %>
    - <%= render :partial=>'layouts/pretty_toolbar' %>
    diff --git a/app/views/themengruppen/verwalten.html.erb b/app/views/themengruppen/verwalten.html.erb index 5522f5f..ce0b343 100644 --- a/app/views/themengruppen/verwalten.html.erb +++ b/app/views/themengruppen/verwalten.html.erb @@ -2,6 +2,8 @@ #themen { list-style-type: none; margin: 0; padding: 0; margin-bottom: 15px;zoom: 1; } #themen li { margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; width: 95%; } +<%= render :partial=>'layouts/pretty_toolbar' %> +
    diff --git a/app/views/themes/2003/themengruppen/verwalten_all.html.erb b/app/views/themes/2003/themengruppen/verwalten_all.html.erb index 827bd69..6367fa7 100644 --- a/app/views/themes/2003/themengruppen/verwalten_all.html.erb +++ b/app/views/themes/2003/themengruppen/verwalten_all.html.erb @@ -1,4 +1,6 @@ +<%= render :partial=>'layouts/pretty_toolbar' %> +
      <% @themengruppen.each do |themengruppe| %>
    • <%= themengruppe.title %>-<%= themengruppe.priority %>
    • @@ -6,7 +8,6 @@