From 13514317c9ee93166637e8d2db218c948e5b717f Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Tue, 27 May 2014 19:41:35 +0530 Subject: [PATCH 01/11] fetprofileprivate data --- app/controllers/fetprofiles_controller.rb | 7 ++++-- app/models/fetprofile.rb | 20 +++++++++++++++- app/views/fetprofiles/_form.html.erb | 23 +++++++++++++++++++ app/views/fetprofiles/_interninfo.html.erb | 13 +++++++++++ app/views/fetprofiles/_internrow.html.erb | 12 ++++++++++ app/views/fetprofiles/internlist.html.erb | 5 ++++ app/views/fetprofiles/show.html.erb | 9 ++++++-- app/views/home/intern.html.erb | 22 +++++++++++++----- config/routes.rb | 1 + ...20140522094444_add_adress_to_fetprofile.rb | 15 ++++++++++++ 10 files changed, 116 insertions(+), 11 deletions(-) create mode 100644 app/views/fetprofiles/_interninfo.html.erb create mode 100644 app/views/fetprofiles/_internrow.html.erb create mode 100644 app/views/fetprofiles/internlist.html.erb create mode 100644 db/migrate/20140522094444_add_adress_to_fetprofile.rb 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/models/fetprofile.rb b/app/models/fetprofile.rb index 787c175..143b672 100644 --- a/app/models/fetprofile.rb +++ b/app/models/fetprofile.rb @@ -15,7 +15,7 @@ # 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 has_many :memberships, dependent: :delete_all has_many :gremien, :through=> :membership mount_uploader :picture, PictureUploader @@ -23,11 +23,18 @@ class Fetprofile < ActiveRecord::Base validates :desc, :presence=>true validates :nachname, length:{minimum: 3},:presence=>true validates :vorname, length:{minimum: 3},:presence=>true + validate :validate_birthday 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 +46,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/views/fetprofiles/_form.html.erb b/app/views/fetprofiles/_form.html.erb index 8143c08..3714148 100644 --- a/app/views/fetprofiles/_form.html.erb +++ b/app/views/fetprofiles/_form.html.erb @@ -28,6 +28,29 @@
<%= f.input :fetmailalias %>
+
+
+Adresse: + +<%=f.input :street %> +<%=f.input :plz %> +<%=f.input :city %> +KOntakt: +<%=f.input :instant %> +<%=f.input :skype %> +<%=f.input :telnr %> +<%=f.input :hdynr %> + +
+
+Geburtstag: +<%=f.input :birth_day %> +<%=f.input :birth_month %> +<%=f.input :birth_year %> + +
+ +
<% @memberships.each do |m| %> <%= f.semantic_fields_for :memberships, m do |membership| %> diff --git a/app/views/fetprofiles/_interninfo.html.erb b/app/views/fetprofiles/_interninfo.html.erb new file mode 100644 index 0000000..b85b608 --- /dev/null +++ b/app/views/fetprofiles/_interninfo.html.erb @@ -0,0 +1,13 @@ +

+ 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/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) %> + From 6451c0f1757da7745db792692ca174d3f339d9b1 Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Mon, 9 Jun 2014 23:14:05 +0530 Subject: [PATCH 07/11] themen ueberarbeitet attachments verwalten --- app/controllers/attachments_controller.rb | 28 ++-- app/controllers/themen_controller.rb | 9 +- app/controllers/wikis_controller.rb | 6 +- app/models/attachment.rb | 15 +- app/models/gremium.rb | 4 +- app/models/thema.rb | 2 +- app/uploaders/attachment_uploader.rb | 6 + app/views/attachments/_attachment.html.erb | 4 +- app/views/attachments/_form_bulk.html.erb | 143 ++++++++++++++++++ app/views/fragen/_form.html.erb | 2 + app/views/fragen/_rform.html.erb | 1 + app/views/themen/_attachment_list.html.erb | 6 + .../themen/_attachment_verwalten.html.erb | 3 + app/views/themen/_form.html.erb | 2 +- app/views/themen/_small.html.erb | 18 ++- app/views/themen/attachments.js.erb | 2 +- app/views/themen/edit.html.erb | 2 +- app/views/themen/edit.js.erb | 2 +- app/views/themen/verwalten.html.erb | 23 ++- app/views/wikis/_form.html.erb | 2 +- app/views/wikis/edit.html.erb | 2 +- app/views/wikis/edit.js.erb | 1 + 22 files changed, 245 insertions(+), 38 deletions(-) create mode 100644 app/views/attachments/_form_bulk.html.erb create mode 100644 app/views/themen/_attachment_verwalten.html.erb create mode 100644 app/views/wikis/edit.js.erb 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/themen_controller.rb b/app/controllers/themen_controller.rb index 4462131..a4a635f 100644 --- a/app/controllers/themen_controller.rb +++ b/app/controllers/themen_controller.rb @@ -32,7 +32,8 @@ class ThemenController < ApplicationController end def verwalten @thema = Thema.find(params[:id]) - unless (@thema.wikiname.empty? || @thema.wikiname.nil?) + @attachment=Attachment.new + unless (@thema.is_wiki?) redirect_to verwalten_wiki_path(Wiki.find(@thema.id)) end @@ -58,7 +59,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 @@ -93,6 +97,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/wikis_controller.rb b/app/controllers/wikis_controller.rb index 1033d07..d448a14 100644 --- a/app/controllers/wikis_controller.rb +++ b/app/controllers/wikis_controller.rb @@ -23,7 +23,11 @@ class WikisController < ApplicationController end def edit @wiki = Wiki.find(params[:id]) - + respond_to do |format| + format.html + format.js + end + end def update 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/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/thema.rb b/app/models/thema.rb index 2a3a9c4..156a3f5 100644 --- a/app/models/thema.rb +++ b/app/models/thema.rb @@ -23,7 +23,7 @@ class Thema < ActiveRecord::Base 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.empty? || wikiname.nil? + wikiname.nil? || wikiname.empty? end def text_first_words md = /

(?[^\<\>]*)/.match Sanitize.clean(self.text,:elements=>['p']) 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/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/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/_small.html.erb b/app/views/themen/_small.html.erb index dfe8095..7cee6e1 100644 --- a/app/views/themen/_small.html.erb +++ b/app/views/themen/_small.html.erb @@ -1,18 +1,22 @@ - -

<%= small.title %>

-
+ +

<%= small.title %>

+
<%= 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/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/wikis/_form.html.erb b/app/views/wikis/_form.html.erb index 18361c3..b17a9e9 100644 --- a/app/views/wikis/_form.html.erb +++ b/app/views/wikis/_form.html.erb @@ -1,6 +1,6 @@ <%= tinymce_assets %>
- <%= semantic_form_for @wiki do |f| %> + <%= semantic_form_for @wiki, :remote=>remote do |f| %> <%= f.inputs do %>
diff --git a/app/views/wikis/edit.html.erb b/app/views/wikis/edit.html.erb index de6c7a3..93d58a1 100644 --- a/app/views/wikis/edit.html.erb +++ b/app/views/wikis/edit.html.erb @@ -1,5 +1,5 @@

Editing thema

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

<%= link_to 'Back', @thema %> diff --git a/app/views/wikis/edit.js.erb b/app/views/wikis/edit.js.erb new file mode 100644 index 0000000..0255518 --- /dev/null +++ b/app/views/wikis/edit.js.erb @@ -0,0 +1 @@ +$("#themaview").html("<%= escape_javascript(raw("

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

")+render(:partial=>"wikis/form", :locals=>{:remote=>true}) )%>"); From 67ccecaf51538069eece25dbf1ae7d371c2e4bf1 Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Tue, 10 Jun 2014 18:47:16 +0530 Subject: [PATCH 08/11] #143 #143 fixed themen fixed --- Gemfile.lock | 29 +++++++++++++++++++++ app/controllers/themen_controller.rb | 4 +-- app/controllers/themengruppen_controller.rb | 9 ++++--- app/controllers/wikis_controller.rb | 8 ++---- app/models/modul.rb | 2 +- app/views/lvas/show.html.erb | 2 +- app/views/themen/_fragen.html.erb | 4 +-- app/views/themen/_small.html.erb | 2 +- app/views/themengruppen/show.html.erb | 11 +++----- app/views/themengruppen/verwalten.html.erb | 2 ++ 10 files changed, 49 insertions(+), 24 deletions(-) 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/themen_controller.rb b/app/controllers/themen_controller.rb index a4a635f..a4fbea3 100644 --- a/app/controllers/themen_controller.rb +++ b/app/controllers/themen_controller.rb @@ -33,9 +33,7 @@ class ThemenController < ApplicationController def verwalten @thema = Thema.find(params[:id]) @attachment=Attachment.new - unless (@thema.is_wiki?) - redirect_to verwalten_wiki_path(Wiki.find(@thema.id)) - end + @fragen=@thema.fragen @toolbar_elements = [{:icon=>:pencil, :hicon=>'icon-pencil', :text=>"Verwalten", :path=>verwalten_thema_path(@thema)}] diff --git a/app/controllers/themengruppen_controller.rb b/app/controllers/themengruppen_controller.rb index ae9fbd9..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 @@ -58,6 +55,12 @@ class ThemengruppenController < ApplicationController 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 index d448a14..a61be11 100644 --- a/app/controllers/wikis_controller.rb +++ b/app/controllers/wikis_controller.rb @@ -16,11 +16,7 @@ class WikisController < ApplicationController redirect_to wiki_path(@wiki) end - def verwalten - @wiki = Wiki.find(params[:id]) - @toolbar_elements = [{:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('wiki.edit'), :path=>edit_wiki_path(@wiki)}] - - end + def edit @wiki = Wiki.find(params[:id]) respond_to do |format| @@ -36,7 +32,7 @@ class WikisController < ApplicationController @wiki.raw_data=params[:wiki][:raw_data] respond_to do |format| if @wiki.update_attributes(params[:wiki]) - format.html { redirect_to @wiki, notice: 'Thema was successfully updated.' } + format.html { redirect_to verwalten_thema_path(@wiki), notice: 'Thema was successfully updated.' } format.json { head :no_content } format.js else 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/views/lvas/show.html.erb b/app/views/lvas/show.html.erb index d5bb9cb..8ef15af 100755 --- a/app/views/lvas/show.html.erb +++ b/app/views/lvas/show.html.erb @@ -7,7 +7,7 @@

Prüfungsinformation

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

Lernaufwand

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 7cee6e1..8c40748 100644 --- a/app/views/themen/_small.html.erb +++ b/app/views/themen/_small.html.erb @@ -1,5 +1,5 @@ -

<%= small.title %>

+

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

<%= raw(small.text) %>
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' %> +
    From 91e04fdeb7849913ed414ad0cdd9d666e9db9545 Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Tue, 10 Jun 2014 20:12:06 +0530 Subject: [PATCH 09/11] gremien for ueberarbeitet --- app/views/gremien/_form.html.erb | 46 ++++++++++++++++---------------- 1 file changed, 23 insertions(+), 23 deletions(-) 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 %> + + + + + + From e3b6eebe1d2ba4cd68b0ed0780d84132a3747c7b Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Wed, 11 Jun 2014 00:37:49 +0530 Subject: [PATCH 10/11] fetprofile form fixed --- app/views/fetprofiles/_form.html.erb | 22 +++++-------------- .../fetprofiles/_membership_fields.html.erb | 13 +++++++++++ 2 files changed, 18 insertions(+), 17 deletions(-) create mode 100644 app/views/fetprofiles/_membership_fields.html.erb diff --git a/app/views/fetprofiles/_form.html.erb b/app/views/fetprofiles/_form.html.erb index b133c30..1467d1f 100644 --- a/app/views/fetprofiles/_form.html.erb +++ b/app/views/fetprofiles/_form.html.erb @@ -47,28 +47,16 @@ Geburtstag: <%=f.input :birth_day %> <%=f.input :birth_month %> <%=f.input :birth_year %> -
    +
    <% @memberships.each do |m| %> - - <%= 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 %> - +<%= render partial:"membership_fields", object: m , locals: {:f=>f} %> +<% end %>
    -
    <%= membership.check_box :_destroy %> <%= I18n.t 'common.delete' %>
    - -
    - <% end %> - <% end %> <% end %> + +<% end %>
    <%= f.actions do %> 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 %> From 0526ea71f2102ce3aa46058b01289a8b537932ca Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Wed, 11 Jun 2014 00:55:46 +0530 Subject: [PATCH 11/11] lvas ueberarbeitet --- app/controllers/application_controller.rb | 2 +- app/models/lva.rb | 6 ++++-- app/views/lvas/_lva.html.erb | 2 +- app/views/lvas/show.html.erb | 2 +- app/views/studien/_semesteransicht.html.erb | 4 ++-- 5 files changed, 9 insertions(+), 7 deletions(-) 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/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/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 8ef15af..a7b8818 100755 --- a/app/views/lvas/show.html.erb +++ b/app/views/lvas/show.html.erb @@ -3,7 +3,7 @@

    <%= notice %>

    -

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

    +

    <%= @lva.full_name %>

    Prüfungsinformation

    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| %>