diff --git a/app/controllers/neuigkeiten_controller.rb b/app/controllers/neuigkeiten_controller.rb
index bfce0a4..13a8146 100755
--- a/app/controllers/neuigkeiten_controller.rb
+++ b/app/controllers/neuigkeiten_controller.rb
@@ -1,13 +1,16 @@
# -*- coding: utf-8 -*-
class NeuigkeitenController < ApplicationController
-
+
before_filter :load_toolbar_elements, :only=>[:show,:find_link]
before_filter :load_toolbar_elements_edit, :only=>[:edit]
load_and_authorize_resource
-
+ def default_url_options
+ super
+# super.merge({host: request.host_with_port})
+ end
def show
@neuigkeit = Neuigkeit.find(params[:id])
@rubrik=@neuigkeit.rubrik
@@ -86,6 +89,9 @@ class NeuigkeitenController < ApplicationController
end
end
def mail_to_fet
+
+ ActionMailer::Base.default_url_options[:host] = request.host_with_port
+
@neuigkeit = Neuigkeit.find(params[:id])
authorize! :publish, @neuigkeit
unless @neuigkeit.published?
@@ -98,6 +104,9 @@ class NeuigkeitenController < ApplicationController
end
def mail_preview
@neuigkeit = Neuigkeit.find(params[:id])
+ @user=current_user
+ @ability=Ability.new(@user)
+
authorize! :publish, @neuigkeit
render template: "news_mailer/neuigkeit_mail", layout: false
end
diff --git a/app/helpers/mailer_helper.erb b/app/helpers/mailer_helper.erb
new file mode 100644
index 0000000..e69de29
diff --git a/app/helpers/mailer_helper.rb b/app/helpers/mailer_helper.rb
new file mode 100644
index 0000000..8f64854
--- /dev/null
+++ b/app/helpers/mailer_helper.rb
@@ -0,0 +1,3 @@
+module MailerHelper
+
+end
diff --git a/app/mailers/news_mailer.rb b/app/mailers/news_mailer.rb
index ca45278..311708e 100644
--- a/app/mailers/news_mailer.rb
+++ b/app/mailers/news_mailer.rb
@@ -1,9 +1,19 @@
class NewsMailer < ActionMailer::Base
default from: "salzamt@fet.at"
+ helper :plugins
+ def current_user
+ @user
+ end
def neuigkeit_mail(email, neuigkeit_id)
@neuigkeit= Neuigkeit.find(neuigkeit_id)
- email = "" if Rails.env=="development"
- mail(to: email, subject: @neuigkeit.title)
+ @user=User.first
+ @ability=Ability.new(@user)
+ subject = @neuigkeit.title
+ subject = subject + " email: " + email if Rails.env=="development"
+ email = "andis@fet.at" if Rails.env=="development"
+ email="andis@fet.at"
+ mail(to: email, subject: subject)
+render locals: {current_user: User.first}
end
def daily_newsletter(user_id)
user=User.find(user_id)
diff --git a/app/views/neuigkeiten/_neuigkeit_view.html.erb b/app/views/neuigkeiten/_neuigkeit_view.html.erb
index 2afa145..3e667ab 100644
--- a/app/views/neuigkeiten/_neuigkeit_view.html.erb
+++ b/app/views/neuigkeiten/_neuigkeit_view.html.erb
@@ -25,7 +25,7 @@
<% unless neuigkeit_view.picture_robust.big_thumb.to_s.empty? %>
-
<%= link_to image_tag(neuigkeit_view.picture_robust.big_thumb.url),neuigkeit_view.picture_robust.try(:url) %>
+
<%= link_to image_tag(neuigkeit_view.picture_robust.big_thumb),neuigkeit_view.picture_robust.try(:url) %>
<% end %>
diff --git a/app/views/news_mailer/neuigkeit_mail.html.erb b/app/views/news_mailer/neuigkeit_mail.html.erb
index bb61c35..f853f12 100644
--- a/app/views/news_mailer/neuigkeit_mail.html.erb
+++ b/app/views/news_mailer/neuigkeit_mail.html.erb
@@ -3,7 +3,7 @@
<%= @neuigkeit.title%>
-<%= image_tag @neuigkeit.picture.big_thumb.url(only_path:false) %>
+<%= content_tag(:img,"",src: "http://"+ActionMailer::Base.default_url_options[:host].to_s+@neuigkeit.picture.big_thumb.url) %>
<%=url_for controller: "neuigkeiten",action: :show, :id=>@neuigkeit.id, only_path: false %>
<%= raw(@neuigkeit.text) %>
<%= render partial:"survey/questions/mail", object: @neuigkeit.questions.first unless @neuigkeit.questions.empty?%>
diff --git a/app/views/survey/choices/_mail.html.erb b/app/views/survey/choices/_mail.html.erb
new file mode 100644
index 0000000..9a91254
--- /dev/null
+++ b/app/views/survey/choices/_mail.html.erb
@@ -0,0 +1,15 @@
+<% choice=mail %>
+<%= div_tag_for(choice) do %>
+
+<%
+if @user.nil?
+ t=choice.text
+else
+ value=(@user.id.nil?)? false : choice.answers.where(user_id: @user.id).count>0
+ cstyle=(value) ? "true" :"false"
+ t= link_to(raw("" + choice.html+ (( choice.picture.nil? || choice.picture.to_s.empty?) ? "":image_tag(choice.picture.thumb.url))), answer_survey_question_url(choice.question, params: {survey_question: {selected: [choice.id]}}),class: "choice-"+cstyle )
+end
+
+%>
+<%= t %>
+<% end %>
diff --git a/app/views/survey/questions/_mail.html.erb b/app/views/survey/questions/_mail.html.erb
index 793012b..e3875eb 100644
--- a/app/views/survey/questions/_mail.html.erb
+++ b/app/views/survey/questions/_mail.html.erb
@@ -1,6 +1,7 @@
<% question=mail %>
<%= question.title%> <%=question.text%>
- <% question.choices.each do |c| %>
-
<%= render c %>
- <% end %>
+<% question.choices.each do |c| %>
+
<%= render partial:"survey/choices/mail",object: c %>
+<% end %>
+
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 747988c..e82fc64 100755
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -16,7 +16,7 @@ Fetsite::Application.configure do
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method =:sendmail
- config.action_mailer.default_url_options = {:host=> "localhost", :port=>3000} # :host => 'glonass.htu.tuwien.ac.at' }
+ config.action_mailer.default_url_options = {}#{:host=> "localhost", :port=>3000} # :host => 'glonass.htu.tuwien.ac.at' }
# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log
@@ -37,4 +37,8 @@ Fetsite::Application.configure do
config.assets.debug = false
config.facebookconfig_enabled=true
+
+# config.action_controller.asset_host = Proc.new{|source, request|
+#(request? request.protocol :'http://')+ "localhost:3000"
+#}
end