Interface Neuigkeiten & Attachment

This commit is contained in:
2014-08-11 14:38:14 +05:30
parent 3347ac89d9
commit af9da058ab
13 changed files with 111 additions and 44 deletions

View File

@@ -40,6 +40,7 @@ class Ability
can :showintern, Thema
can :manage, Thema
can :manage, Themengruppe
can :manage, Attachment
end
unless user.has_role?("fetadmin")
cannot :delete, Themengruppe

View File

@@ -18,6 +18,13 @@ class Attachment < ActiveRecord::Base
validates :thema, :presence => true
validates :name, :presence => true
def image?
# data_ext = datei.file.extension.downcase
# %w(jpg png jpeg).include?(data_ext)
datei.image?(datei.file)
end
def to_jq_upload
{
"id" => read_attribute(:id),

View File

@@ -49,7 +49,9 @@ include Rails.application.routes.url_helpers
def fix_links(host)
full_url= URI.parse(root_url(:host=>host))
self.text.gsub!(/src="[^"]*attachment\/datei\/(\d+)[^"]*"/){|s| full_url.path=Attachment.find($1.to_i).datei.url; 'src="'+full_url.to_s+'"'}
self.text.gsub!(/src="[\.\/]*uploads\/attachment\/datei\/(\d+)\/thumb_big[^"]*"/){|s| full_url.path=Attachment.find($1.to_i).datei.thumb_big.url; 'src="'+full_url.to_s+'"'}
self.text.gsub!(/src="[\.\/^"]*uploads\/attachment\/datei\/(\d+)\/[^"]*"/){|s| full_url.path=Attachment.find($1.to_i).datei.url; 'src="'+full_url.to_s+'"'}
self.text.gsub!(/href="[^"]*themen\/(\d+)[^"]*"/){|s| full_url.path=thema_path(Thema.find($1.to_i)); 'href="'+full_url.to_s+'"'}
end