forked from bofh/fetsite
modify attachments
This commit is contained in:
@@ -13,6 +13,15 @@ class AttachmentsController < ApplicationController
|
|||||||
|
|
||||||
# GET /attachments/1
|
# GET /attachments/1
|
||||||
# GET /attachments/1.json
|
# GET /attachments/1.json
|
||||||
|
def set_titlepic
|
||||||
|
@attachment = Attachment.find(params[:id])
|
||||||
|
if @attachment.image?
|
||||||
|
@attachment.flag_titlepic = params[:titlepic]
|
||||||
|
@attachment.thema.titlepics << @attachment
|
||||||
|
@attachment.save
|
||||||
|
end
|
||||||
|
redirect_to @attachment.thema
|
||||||
|
end
|
||||||
def show
|
def show
|
||||||
@attachment = Attachment.find(params[:id])
|
@attachment = Attachment.find(params[:id])
|
||||||
|
|
||||||
|
|||||||
@@ -12,12 +12,12 @@
|
|||||||
|
|
||||||
class Attachment < ActiveRecord::Base
|
class Attachment < ActiveRecord::Base
|
||||||
has_paper_trail
|
has_paper_trail
|
||||||
attr_accessible :name, :datei, :datei_cache
|
attr_accessible :name, :datei, :datei_cache,:flag_titlepic
|
||||||
belongs_to :thema
|
belongs_to :thema
|
||||||
mount_uploader :datei, AttachmentUploader
|
mount_uploader :datei, AttachmentUploader
|
||||||
validates :thema, :presence => true
|
validates :thema, :presence => true
|
||||||
validates :name, :presence => true
|
validates :name, :presence => true
|
||||||
|
belongs_to :parent, :polymorphic=>true
|
||||||
def image?
|
def image?
|
||||||
|
|
||||||
# data_ext = datei.file.extension.downcase
|
# data_ext = datei.file.extension.downcase
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ include Rails.application.routes.url_helpers
|
|||||||
validates :themengruppe, :presence => true
|
validates :themengruppe, :presence => true
|
||||||
validates :title, :presence => true
|
validates :title, :presence => true
|
||||||
validates :text, :presence => true
|
validates :text, :presence => true
|
||||||
|
has_many :titlepics, :as=>:parent, :class_name=>'Attachment', :conditions=>{:flag_titlepic=>true}
|
||||||
has_many :meetings, :as=>:parent
|
has_many :meetings, :as=>:parent
|
||||||
has_many :documents, :as=>:parent
|
has_many :documents, :as=>:parent
|
||||||
scope :public, where(:isdraft=>false).includes(:themengruppe).where("themengruppen.public"=>true)
|
scope :public, where(:isdraft=>false).includes(:themengruppe).where("themengruppen.public"=>true)
|
||||||
|
|||||||
@@ -12,6 +12,9 @@
|
|||||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Actions</a>
|
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Actions</a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li>
|
<li>
|
||||||
|
<%= link_to ff_icon("icon-pencil")+"Make Titlepic", set_titlepic_thema_attachment_path(a.thema,a,:params=>{:titlepic=>true}) %>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
<%= link_to ff_icon("icon-pencil")+"Edit", edit_thema_attachment_path(a.thema,a) %>
|
<%= link_to ff_icon("icon-pencil")+"Edit", edit_thema_attachment_path(a.thema,a) %>
|
||||||
</li><li>
|
</li><li>
|
||||||
<%= link_to "Delete Attachment", thema_attachment_path(a.thema,a), method: "DELETE", confirm: "Sure?" , class: "btn-danger " %>
|
<%= link_to "Delete Attachment", thema_attachment_path(a.thema,a), method: "DELETE", confirm: "Sure?" , class: "btn-danger " %>
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<% if can? :show, small %>
|
<% if can? :show, small %>
|
||||||
<a name="thema_<%=small.id%>" href="#<%=small.id%>">
|
<a name="thema_<%=small.id%>" href="#<%=small.id%>">
|
||||||
<h2><%= small.title %> <%= link_to fa_icon("pencil"), verwalten_thema_path(small) if can? :edit, small %> </h2>
|
<h2><%= link_to small.title,small %> <%= link_to fa_icon("pencil"), verwalten_thema_path(small) if can? :edit, small %> </h2>
|
||||||
</a>
|
</a>
|
||||||
|
<%= image_tag small.titlepics.first.datei.url unless small.titlepics.first.nil? %>
|
||||||
<% if small.is_outdated? %>
|
<% if small.is_outdated? %>
|
||||||
<div class="sticker sticker-red"> <%= I18n.t("thema.outdated") %> <%= link_to"Als aktuell markieren",is_updated_thema_path(small), :class=>:btn if can? :is_updated, small%></div>
|
<div class="sticker sticker-red"> <%= I18n.t("thema.outdated") %> <%= link_to"Als aktuell markieren",is_updated_thema_path(small), :class=>:btn if can? :is_updated, small%></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,19 +1,24 @@
|
|||||||
<%= content_for :header do %>
|
<%= content_for :header do %>
|
||||||
<title><%= @thema.title.to_s + " (" + @thema.themengruppe.title.to_s + ")" %></title>
|
<title><%= @thema.title.to_s + " (" + @thema.themengruppe.title.to_s + ")" %></title>
|
||||||
|
|
||||||
<% unless @thema.attachments.first.nil?
|
<%
|
||||||
# picture_url=URI(root_url)
|
mog = {
|
||||||
# picture_url.path=@thema.picture.url(:locale=>nil, :theme=>nil)
|
|
||||||
end
|
|
||||||
%>
|
|
||||||
<% set_meta_tags :og => {
|
|
||||||
:title => @thema.title.to_s + " (" + @thema.themengruppe.title.to_s + ")",
|
:title => @thema.title.to_s + " (" + @thema.themengruppe.title.to_s + ")",
|
||||||
:type => "article",
|
:type => "article",
|
||||||
:description =>@thema.text_first_words,
|
:description =>@thema.text_first_words,
|
||||||
:url=>thema_url(:theme=>nil)
|
:url=>thema_url(:theme=>nil)
|
||||||
}
|
}
|
||||||
%>
|
%>
|
||||||
<%= display_meta_tags %>
|
|
||||||
|
<%=
|
||||||
|
unless @thema.titlepics.first.nil?
|
||||||
|
picture_url=URI(root_url)
|
||||||
|
picture_url.path=@thema.titlepics.first.datei.url(:locale=>nil, :theme=>nil)
|
||||||
|
mog[:image]= picture_url
|
||||||
|
end
|
||||||
|
%>
|
||||||
|
<%= mog.to_yaml %>
|
||||||
|
<%= display_meta_tags :og=> mog %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<p id="notice"><%= notice %></p>
|
<p id="notice"><%= notice %></p>
|
||||||
|
|||||||
@@ -157,7 +157,11 @@
|
|||||||
get :documents
|
get :documents
|
||||||
get :meetings
|
get :meetings
|
||||||
end
|
end
|
||||||
resources :attachments
|
resources :attachments do
|
||||||
|
member do
|
||||||
|
get :set_titlepic
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :calendars
|
resources :calendars
|
||||||
|
|||||||
7
db/migrate/20150211180445_add_parent_to_attachment.rb
Normal file
7
db/migrate/20150211180445_add_parent_to_attachment.rb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
class AddParentToAttachment < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
change_table :attachments do |t|
|
||||||
|
t.references :parent, :polymorphic=>{:default=>'Thema'}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
5
db/migrate/20150211180912_add_flags_to_attachment.rb
Normal file
5
db/migrate/20150211180912_add_flags_to_attachment.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
class AddFlagsToAttachment < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :attachments, :flag_titlepic, :boolean
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user