meeting style

This commit is contained in:
Andreas Stephanides
2015-03-15 13:09:05 +01:00
parent 3cc9de7d29
commit 34c0374877
11 changed files with 55 additions and 24 deletions

View File

@@ -21,6 +21,7 @@ class MeetingsController < ApplicationController
m=Meeting.find(params[:id]) m=Meeting.find(params[:id])
m.create_announcement(current_user) m.create_announcement(current_user)
m.save m.save
@meeting=Meeting.find(params[:id])
respond_to do |format| respond_to do |format|
format.html {redirect_to m.parent} format.html {redirect_to m.parent}

View File

@@ -85,9 +85,17 @@ end
summary summary
end end
end end
def text def icon_text
I18n.l(self.start) +" "+ I18n.t("cal.bis")+" "+ I18n.l(self.ende) ApplicationController.helpers.fa_icon("calendar 2x") + self.text
end 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 :public, -> { where(:public => :true) }
# scope :upcoming, -> { where("start >= ?" , Time.now).where("start <= ?", 28.days.from_now) } # scope :upcoming, -> { where("start >= ?" , Time.now).where("start <= ?", 28.days.from_now) }
end end

View File

@@ -21,6 +21,7 @@ class Meeting < ActiveRecord::Base
def title def title
self.text self.text
end end
def text def text
unless self.meetingtyp.try(:name).to_s.empty? unless self.meetingtyp.try(:name).to_s.empty?
t = self.meetingtyp.name.to_s+", " t = self.meetingtyp.name.to_s+", "
@@ -29,18 +30,23 @@ class Meeting < ActiveRecord::Base
t = parent.title.to_s + ", " if self.name.empty? t = parent.title.to_s + ", " if self.name.empty?
end end
t= t+ self.name.to_s 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 t
end end
def create_announcement(user) def create_announcement(user)
if self.neuigkeit.nil?
n = Neuigkeit.new n = Neuigkeit.new
n.title=self.text n.title=self.text
n.text ="Agenda im Anhang" n.text ="Agenda im Anhang"
n.rubrik = self.meetingtyp.rubrik n.rubrik = self.meetingtyp.rubrik
n.author=user n.author=user
n.save
self.neuigkeit= n self.neuigkeit= n
end end
end
def fix_calentry def fix_calentry
self.calentry.object=self unless self.calentry.nil? self.calentry.object=self unless self.calentry.nil?
self.calentry.calendar = self.meetingtyp.rubrik.calendar self.calentry.calendar = self.meetingtyp.rubrik.calendar

View File

@@ -1,12 +1,15 @@
class Meetingtyp < ActiveRecord::Base class Meetingtyp < ActiveRecord::Base
attr_accessible :agendaintern, :desc, :name, :protocolintern, :rubrik_id attr_accessible :agendaintern, :desc, :name, :protocolintern, :rubrik_id, :picture
belongs_to :rubrik belongs_to :rubrik
validate :rubrik, :presence=>true validate :rubrik, :presence=>true
has_many :meetings has_many :meetings
has_one :calendar, through: :rubrik has_one :calendar, through: :rubrik
has_one :protocol, :class_name=>'Document', :conditions=>{:typ=>10}, :as=>:parent has_one :protocol, :class_name=>'Document', :conditions=>{:typ=>10}, :as=>:parent
has_one :agenda , :as=>:parent, :conditions=>{:typ=>11}, :class_name=>'Document' has_one :agenda , :as=>:parent, :conditions=>{:typ=>11}, :class_name=>'Document'
def text
self.name mount_uploader :picture, PictureUploader
end
def text
self.name
end
end end

View File

@@ -39,7 +39,17 @@ class Neuigkeit < ActiveRecord::Base
before_validation :sanitize before_validation :sanitize
after_save :update_cache 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? def is_annoncement?
!self.meeting.nil? !self.meeting.nil?
end end

View File

@@ -1,13 +1,6 @@
<div class="contentbox" id="calentry_<%= calentry.id%>"> <div class="contentbox" id="calentry_<%= calentry.id%>">
<% image_tag("/iconnavy/time.png") %> <% image_tag("/iconnavy/time.png") %>
<%= fa_icon("calendar 2x") %> <%= calentry.icon_text %>
<% if (calentry.start.to_date - calentry.ende.to_date) < 1.day
format=:timeonly
else
format =:default
end %>
<%= calentry.text %>
<% if !(defined? manage) || manage %> <% if !(defined? manage) || manage %>
<%= link_to "edit", edit_calentry_path(calentry),:remote=>true if can? :edit, calentry %> <%= 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 %> <%= link_to 'Delete', calentry, method: :delete, data: { confirm: 'Are you sure?' } , remote: true if can? :delete, calentry %>

View File

@@ -1,11 +1,11 @@
<div class="contentbox" id="meeting_<%= meeting.id%>"> <div class="contentbox" id="meeting_<%= meeting.id%>">
<b><%= link_to meeting.text, meeting %></b> <b><%= image_tag meeting.meetingtyp.picture.thumb.url unless meeting.meetingtyp.picture.thumb.url.nil? %><%= link_to meeting.text.html_safe, meeting %></b>
<%= link_to "Ankündigung", rubrik_neuigkeit_path(meeting.neuigkeit.rubrik, meeting.neuigkeit) unless meeting.neuigkeit.nil? %> <%= 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 "ankündigen", announce_meeting_path(meeting), remote: true if meeting.neuigkeit.nil? %>
<%= link_to "edit", edit_meeting_path(meeting), remote: true %> <%= 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 %> <%= 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 "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? %> <%= link_to "Protokoll" , create_protocol_meeting_path(meeting),:remote=>true if meeting.protocol.nil? %>
<%= render meeting.agenda unless meeting.agenda.nil? %> <%= render meeting.agenda unless meeting.agenda.nil? %>

View File

@@ -4,6 +4,9 @@
<%= f.input :rubrik %> <%= f.input :rubrik %>
<%= f.input :agendaintern %> <%= f.input :agendaintern %>
<%= f.input :protocolintern %> <%= f.input :protocolintern %>
<%= image_tag @meetingtyp.picture.thumb.url %>
<%= f.input :picture %>
<% end %> <% end %>
<%= f.actions do %> <%= f.actions do %>
<%= f.action :submit, :as => :input %> <%= f.action :submit, :as => :input %>

View File

@@ -1,8 +1,10 @@
<div class="media" itemscope itemtype="http://schema.org/Article"> <div class="media" itemscope itemtype="http://schema.org/Article">
<meta itemprop="sameAs" content="<%= rubrik_neuigkeit_path(neuigkeit.rubrik,neuigkeit, {theme: nil,locale: nil})%>"/> <meta itemprop="sameAs" content="<%= rubrik_neuigkeit_path(neuigkeit.rubrik,neuigkeit, {theme: nil,locale: nil})%>"/>
<meta itemprop="url" content="<%= rubrik_neuigkeit_path(neuigkeit.rubrik,neuigkeit, {theme: nil,locale: nil})%>"/>
<div class="pull-left" href="#"> <div class="pull-left" href="#">
<p><br> <p><br>
<% unless neuigkeit.picture.url.nil? %><%= image_tag neuigkeit.picture.thumb.url %> <meta imageprop="thumbnailUrl" content="<%= neuigkeit.picture.thumb.url%>"/> <% unless neuigkeit.picture_robust.url.nil? %><%= image_tag neuigkeit.picture_robust.thumb.url %> <meta imageprop="thumbnailUrl" content="<%= neuigkeit.picture_robust.thumb.url%>"/>
<% end %> </p> <% end %> </p>
</div> </div>
<div class="media-body"> <div class="media-body">

View File

@@ -1,9 +1,9 @@
<%= content_for :header do %> <%= content_for :header do %>
<title>Fetsite - <%= @neuigkeit.title %> (<%= @neuigkeit.rubrik.name %>)</title> <title>Fetsite - <%= @neuigkeit.title %> (<%= @neuigkeit.rubrik.name %>)</title>
<% set_meta_tags :author => fetprofile_path(@neuigkeit.author.fetprofile) unless @neuigkeit.author.fetprofile.nil? %> <% 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=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 end
%> %>
<% set_meta_tags :og => { <% set_meta_tags :og => {
@@ -49,9 +49,9 @@ end
<div class="sticker sticker-red"> Not Published</div> <% end %> <div class="sticker sticker-red"> Not Published</div> <% end %>
<div class="media"> <div class="media">
<% unless @neuigkeit.picture.big_thumb.to_s.empty? %> <% unless @neuigkeit.picture_robust.big_thumb.to_s.empty? %>
<div class="pull-left" href="#"> <div class="pull-left" href="#">
<p><br><%= link_to image_tag(@neuigkeit.picture.big_thumb.url),@neuigkeit.picture.try(:url) %> <p><br><%= link_to image_tag(@neuigkeit.picture_robust.big_thumb.url),@neuigkeit.picture_robust.try(:url) %>
</p> </p>
</div> </div>
<% end %> <% end %>

View File

@@ -0,0 +1,5 @@
class AddPictureToMeetingtyps < ActiveRecord::Migration
def change
add_column :meetingtyps, :picture, :string
end
end