diff --git a/app/controllers/meetings_controller.rb b/app/controllers/meetings_controller.rb index c666945..5fc7193 100644 --- a/app/controllers/meetings_controller.rb +++ b/app/controllers/meetings_controller.rb @@ -21,6 +21,7 @@ class MeetingsController < ApplicationController m=Meeting.find(params[:id]) m.create_announcement(current_user) m.save + @meeting=Meeting.find(params[:id]) respond_to do |format| format.html {redirect_to m.parent} diff --git a/app/models/calentry.rb b/app/models/calentry.rb index 2f8d2fe..2d55bbb 100644 --- a/app/models/calentry.rb +++ b/app/models/calentry.rb @@ -85,9 +85,17 @@ end summary end end -def text - I18n.l(self.start) +" "+ I18n.t("cal.bis")+" "+ I18n.l(self.ende) -end + def icon_text + ApplicationController.helpers.fa_icon("calendar 2x") + self.text + end + def text + if (self.start.to_date - self.ende.to_date) < 1.day + format=:timeonly + else + format =:default + end + I18n.l(self.start) +" "+ I18n.t("cal.bis")+" "+ I18n.l(self.ende, :format=>format) + end scope :public, -> { where(:public => :true) } # scope :upcoming, -> { where("start >= ?" , Time.now).where("start <= ?", 28.days.from_now) } end diff --git a/app/models/meeting.rb b/app/models/meeting.rb index a8e3ff1..fffb525 100644 --- a/app/models/meeting.rb +++ b/app/models/meeting.rb @@ -21,6 +21,7 @@ class Meeting < ActiveRecord::Base def title self.text end + def text unless self.meetingtyp.try(:name).to_s.empty? t = self.meetingtyp.name.to_s+", " @@ -29,17 +30,22 @@ class Meeting < ActiveRecord::Base t = parent.title.to_s + ", " if self.name.empty? end t= t+ self.name.to_s - t = t + " " + I18n.l(self.calentry.start) unless self.calentry.nil? + # t = t + " " + I18n.l(self.calentry.start) unless self.calentry.nil? + t = t +" am "+ self.calentry.text unless self.calentry.nil? t end def create_announcement(user) + if self.neuigkeit.nil? n = Neuigkeit.new n.title=self.text n.text ="Agenda im Anhang" n.rubrik = self.meetingtyp.rubrik n.author=user + n.save self.neuigkeit= n + end + end def fix_calentry self.calentry.object=self unless self.calentry.nil? diff --git a/app/models/meetingtyp.rb b/app/models/meetingtyp.rb index bcbdd19..48e114d 100644 --- a/app/models/meetingtyp.rb +++ b/app/models/meetingtyp.rb @@ -1,12 +1,15 @@ class Meetingtyp < ActiveRecord::Base - attr_accessible :agendaintern, :desc, :name, :protocolintern, :rubrik_id + attr_accessible :agendaintern, :desc, :name, :protocolintern, :rubrik_id, :picture belongs_to :rubrik validate :rubrik, :presence=>true has_many :meetings has_one :calendar, through: :rubrik has_one :protocol, :class_name=>'Document', :conditions=>{:typ=>10}, :as=>:parent has_one :agenda , :as=>:parent, :conditions=>{:typ=>11}, :class_name=>'Document' -def text -self.name -end + + mount_uploader :picture, PictureUploader + + def text + self.name + end end diff --git a/app/models/neuigkeit.rb b/app/models/neuigkeit.rb index 17ebc8f..18a0c8e 100755 --- a/app/models/neuigkeit.rb +++ b/app/models/neuigkeit.rb @@ -39,7 +39,17 @@ class Neuigkeit < ActiveRecord::Base before_validation :sanitize after_save :update_cache - + def picture_robust + unless self.picture.url.nil? + return self.picture + else + if self.has_meeting? + return self.meeting.meetingtyp.picture + else + return self.picture + end + end + end def is_annoncement? !self.meeting.nil? end diff --git a/app/views/calentries/_calentry.html.erb b/app/views/calentries/_calentry.html.erb index d96f6b6..787c5de 100644 --- a/app/views/calentries/_calentry.html.erb +++ b/app/views/calentries/_calentry.html.erb @@ -1,13 +1,6 @@
<% image_tag("/iconnavy/time.png") %> - <%= fa_icon("calendar 2x") %> - - <% if (calentry.start.to_date - calentry.ende.to_date) < 1.day - format=:timeonly - else - format =:default - end %> - <%= calentry.text %> + <%= calentry.icon_text %> <% if !(defined? manage) || manage %> <%= link_to "edit", edit_calentry_path(calentry),:remote=>true if can? :edit, calentry %> <%= link_to 'Delete', calentry, method: :delete, data: { confirm: 'Are you sure?' } , remote: true if can? :delete, calentry %> diff --git a/app/views/meetings/_meeting.html.erb b/app/views/meetings/_meeting.html.erb index 08c3362..804c46b 100644 --- a/app/views/meetings/_meeting.html.erb +++ b/app/views/meetings/_meeting.html.erb @@ -1,11 +1,11 @@
-<%= link_to meeting.text, meeting %> +<%= image_tag meeting.meetingtyp.picture.thumb.url unless meeting.meetingtyp.picture.thumb.url.nil? %><%= link_to meeting.text.html_safe, meeting %> <%= link_to "Ankündigung", rubrik_neuigkeit_path(meeting.neuigkeit.rubrik, meeting.neuigkeit) unless meeting.neuigkeit.nil? %> <%= link_to "ankündigen", announce_meeting_path(meeting), remote: true if meeting.neuigkeit.nil? %> <%= link_to "edit", edit_meeting_path(meeting), remote: true %> <%= link_to 'Delete', meeting, method: :delete, data: { confirm: 'Are you sure?' } , remote: true if can? :delete, meeting %> -<%= render meeting.calentry, locals: {manage: 0} unless meeting.calentry.nil? %> +<% render meeting.calentry, locals: {manage: 0} unless meeting.calentry.nil? %> <%= link_to "Agenda" , create_agenda_meeting_path(meeting), :remote=>true if meeting.agenda.nil? %> <%= link_to "Protokoll" , create_protocol_meeting_path(meeting),:remote=>true if meeting.protocol.nil? %> <%= render meeting.agenda unless meeting.agenda.nil? %> diff --git a/app/views/meetingtyps/_form.html.erb b/app/views/meetingtyps/_form.html.erb index 5a21d57..74f06c3 100644 --- a/app/views/meetingtyps/_form.html.erb +++ b/app/views/meetingtyps/_form.html.erb @@ -4,6 +4,9 @@ <%= f.input :rubrik %> <%= f.input :agendaintern %> <%= f.input :protocolintern %> + <%= image_tag @meetingtyp.picture.thumb.url %> + <%= f.input :picture %> + <% end %> <%= f.actions do %> <%= f.action :submit, :as => :input %> diff --git a/app/views/neuigkeiten/_compact.html.erb b/app/views/neuigkeiten/_compact.html.erb index 129f5d1..d242424 100644 --- a/app/views/neuigkeiten/_compact.html.erb +++ b/app/views/neuigkeiten/_compact.html.erb @@ -1,8 +1,10 @@
+ +


-<% unless neuigkeit.picture.url.nil? %><%= image_tag neuigkeit.picture.thumb.url %> +<% unless neuigkeit.picture_robust.url.nil? %><%= image_tag neuigkeit.picture_robust.thumb.url %> <% end %>

diff --git a/app/views/neuigkeiten/show.html.erb b/app/views/neuigkeiten/show.html.erb index ca0dd9d..bc66d94 100755 --- a/app/views/neuigkeiten/show.html.erb +++ b/app/views/neuigkeiten/show.html.erb @@ -1,9 +1,9 @@ <%= content_for :header do %> Fetsite - <%= @neuigkeit.title %> (<%= @neuigkeit.rubrik.name %>) <% set_meta_tags :author => fetprofile_path(@neuigkeit.author.fetprofile) unless @neuigkeit.author.fetprofile.nil? %> -<% unless @neuigkeit.picture.url.nil? +<% unless @neuigkeit.picture_robust.url.nil? picture_url=URI(root_url) - picture_url.path=@neuigkeit.picture.url(:locale=>nil, :theme=>nil) + picture_url.path=@neuigkeit.picture_robust.url(:locale=>nil, :theme=>nil) end %> <% set_meta_tags :og => { @@ -49,9 +49,9 @@ end
Not Published
<% end %>
- <% unless @neuigkeit.picture.big_thumb.to_s.empty? %> + <% unless @neuigkeit.picture_robust.big_thumb.to_s.empty? %>
-


<%= link_to image_tag(@neuigkeit.picture.big_thumb.url),@neuigkeit.picture.try(:url) %> +


<%= link_to image_tag(@neuigkeit.picture_robust.big_thumb.url),@neuigkeit.picture_robust.try(:url) %>

<% end %> diff --git a/db/migrate/20150315093427_add_picture_to_meetingtyps.rb b/db/migrate/20150315093427_add_picture_to_meetingtyps.rb new file mode 100644 index 0000000..83fc0f1 --- /dev/null +++ b/db/migrate/20150315093427_add_picture_to_meetingtyps.rb @@ -0,0 +1,5 @@ +class AddPictureToMeetingtyps < ActiveRecord::Migration + def change + add_column :meetingtyps, :picture, :string + end +end