forked from bofh/fetsite
facebookpublish,themen fixes
This commit is contained in:
@@ -61,6 +61,7 @@ class Ability
|
||||
if( user.has_role?("fetadmin"))
|
||||
can [:delete],Calendar
|
||||
can [:delete],Calentry
|
||||
can :doadmin, User
|
||||
end
|
||||
|
||||
# Rechteverwaltung fuer Neuigkeiten
|
||||
|
||||
@@ -46,7 +46,7 @@ class Neuigkeit < ActiveRecord::Base
|
||||
self.rubrik.public
|
||||
end
|
||||
def published?
|
||||
self.datum_nilsave>=Time.now.to_date
|
||||
self.datum_nilsave<Time.now.to_date
|
||||
end
|
||||
|
||||
def publish
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
# updated_at :datetime not null
|
||||
# themengruppe_id :integer
|
||||
#
|
||||
|
||||
require 'uri'
|
||||
class Thema < ActiveRecord::Base
|
||||
include Rails.application.routes.url_helpers
|
||||
attr_accessible :text, :title, :themengruppe_id
|
||||
has_many :fragen
|
||||
has_many :attachments
|
||||
@@ -23,7 +24,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.nil? || wikiname.empty?
|
||||
!(wikiname.nil? || wikiname.empty?)
|
||||
end
|
||||
def text_first_words
|
||||
md = /<p>(?<text>[^\<\>]*)/.match Sanitize.clean(self.text,:elements=>['p'])
|
||||
@@ -36,4 +37,10 @@ class Thema < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
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!(/href="[^"]*themen\/(\d+)[^"]*"/){|s| full_url.path=thema_path(Thema.find($1.to_i)); 'href="'+full_url.to_s+'"'}
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -22,6 +22,7 @@ class Themengruppe < ActiveRecord::Base
|
||||
translates :title,:text, :versioning =>true, :fallbacks_for_empty_translations => true
|
||||
|
||||
scope :intern,-> {where(:public=>false)}
|
||||
scope :public,-> {where(:public=>true)}
|
||||
|
||||
def self.find_wiki_default
|
||||
where(:wiki_default=>true).first
|
||||
|
||||
@@ -38,16 +38,17 @@ belongs_to :fetprofile
|
||||
def self.find_for_facebook_oauth(auth, signed_in_resource=nil)
|
||||
logger.debug auth.to_s
|
||||
logger.debug "DDD Username= #{auth.username}"
|
||||
user = User.where(:provider => auth.provider, :uid => auth.extra.raw_info.uid).first
|
||||
user = User.where(:provider => auth.provider, :uid => auth.uid).first
|
||||
unless user
|
||||
user = User.create(name:auth.uid,
|
||||
user = User.create(name: auth.uid,
|
||||
provider:auth.provider,
|
||||
uid:auth.uid,
|
||||
uid: auth.uid,
|
||||
email:auth.info.email,
|
||||
password:Devise.friendly_token[0,20]
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
user
|
||||
end
|
||||
def self.find_for_ldap_oauth(auth,signed_in_resource=nil)
|
||||
|
||||
Reference in New Issue
Block a user