Merge branch 'master' into 'master'

Edit singup's uploaded filename display. Edit email contents of file upload or edit.

See merge request spen/seminar!47
This commit is contained in:
chiu 2022-06-18 15:15:39 +00:00
commit 93cfa14e46
8 changed files with 109 additions and 19 deletions

View File

@ -515,7 +515,13 @@ class SeminarsController < ApplicationController
signup = SeminarSignup.where(id:update_params['seminar_signup_id']).first
seminar_id = signup.seminar_main_id
@seminar = SeminarMain.where(id:seminar_id).first
send_mail('add_file',signup.email,seminar_id)
host_url = Site.first.root_url
if host_url == "http://"
host_url = request.protocol + request.host_with_port
end
extra_text = "<br>"+render_to_string("seminars/con_email_contents",:locals=>{:@seminar=>@seminar,
:@con=>@con,:@host_url=>host_url},:layout=>false)
send_mail('add_file',signup.email,seminar_id,extra_text)
seminar_reviews = SeminarReview.where(:seminar_main_id=>signup.seminar_main_id).to_a
seminar_reviews.each{|sr| sr.save}
@seminar = signup.seminar_main
@ -559,7 +565,13 @@ class SeminarsController < ApplicationController
signup = SeminarSignup.where(id:update_params['seminar_signup_id']).first
seminar_id = signup.seminar_main_id
@seminar = SeminarMain.where(id:seminar_id).first
send_mail('edit_file',signup.email,seminar_id)
host_url = Site.first.root_url
if host_url == "http://"
host_url = request.protocol + request.host_with_port
end
extra_text = "<br>"+render_to_string("seminars/con_email_contents",:locals=>{:@seminar=>@seminar,
:@con=>@con,:@host_url=>host_url},:layout=>false)
send_mail('edit_file',signup.email,seminar_id,extra_text)
seminar_reviews = SeminarReview.where(:seminar_main_id=>signup.seminar_main_id).to_a
seminar_reviews.each{|sr| sr.save}
@seminar = signup.seminar_main

View File

@ -8,6 +8,7 @@ class SeminarSignupContribute
field :presentation_type , type: String , default: ""
field :sort_number , type: Integer, default: 10000
mount_uploader :file, AssetUploader
field :filename, type: String
field :description
field :preferred_session
field :final_session
@ -40,4 +41,25 @@ class SeminarSignupContribute
end
end
end
before_save do
self.update_filename
end
def update_filename
if self.title.blank?
self.filename = self.file.file.filename rescue ''
else
if self.file.file
self.filename = self.title.sub(/#{::Regexp.escape(File.extname(self.title))}$/,'') + File.extname(self.file.file.filename)
else
self.filename = self.title
end
end
self.filename
end
def disp_filename
if self.filename.nil?
self.class.where(:id=>self.id).update_all(:filename=>self.update_filename)
end
self.filename
end
end

View File

@ -56,6 +56,7 @@
end %>
<% file_path = seminar_signup_contribute.file.path %>
<% file_title = (seminar_signup_contribute.title.blank? ? File.basename(seminar_signup_contribute.file.path) : seminar_signup_contribute.title) %>
<% filename = seminar_signup_contribute.disp_filename %>
<% file_url = seminar_signup_contribute.file.url %>
<% file_extname = File.extname(file_path) %>
<% if (file_extname.match(/pdf/i) rescue false) %>
@ -69,9 +70,9 @@
<% file_content = File.read(file_path) rescue "" %>
<% if file_content.is_utf8? %>
<% file_content = file_content.gsub(/(\r\n|\n)/,"<br>")%>
<% val = "<div class=\"text_wrap\"><a class=\"pull-right\" href=\"#{file_url}\" title=\"#{t(:download)}\">#{t(:download)}</a><div style=\"clear: both;\"></div><h4>#{file_title}</h4>#{file_content}</div>"%>
<% val = "<div class=\"text_wrap\"><a class=\"pull-right\" href=\"#{file_url}\" title=\"#{t(:download)}\" download=\"#{filename}\">#{t(:download)}</a><div style=\"clear: both;\"></div><h4>#{file_title}</h4>#{file_content}</div>"%>
<% else %>
<% val = link_to( file_title, file_url , {:target => '_blank', :title => Nokogiri::HTML(description.gsub("<br>"," , ")).text} ) if seminar_signup_contribute.file.file %>
<% val = link_to( file_title, file_url , {:target => '_blank', :title => Nokogiri::HTML(description.gsub("<br>"," , ")).text, :download=>filename} ) if seminar_signup_contribute.file.file %>
<% end %>
<% end %>
<% else %>

View File

@ -141,7 +141,7 @@
description = seminar_signup_contribute.description.map{|i| @seminar.summary_chioices[i.to_i] rescue "" }.join("<br>") rescue seminar_signup_contribute.description
end
end %>
<%= link_to (seminar_signup_contribute.title.blank? ? File.basename(seminar_signup_contribute.file.path) : seminar_signup_contribute.title) , seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(description.gsub("<br>"," , ")).text} if seminar_signup_contribute.file.file %>
<%= link_to seminar_signup_contribute.disp_filename , seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(description.gsub("<br>"," , ")).text, :download=>seminar_signup_contribute.disp_filename} if seminar_signup_contribute.file.file %>
<% else %>
<%= val[0].html_safe.to_s rescue "" %>
<% end %>
@ -185,7 +185,7 @@
description = seminar_signup_contribute.description.map{|i| @seminar.summary_chioices[i.to_i] rescue "" }.join("<br>") rescue seminar_signup_contribute.description
end
end %>
<%= link_to (seminar_signup_contribute.title.blank? ? File.basename(seminar_signup_contribute.file.path) : seminar_signup_contribute.title) , seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(description.gsub("<br>"," , ")).text} if seminar_signup_contribute.file.file %>
<%= link_to seminar_signup_contribute.disp_filename , seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(description.gsub("<br>"," , ")).text, :download=>seminar_signup_contribute.disp_filename} if seminar_signup_contribute.file.file %>
<% else %>
<%= val.html_safe.to_s rescue "" %>
<% end %>

View File

@ -6,3 +6,4 @@
<% else %>
<%= t('seminar.email_add_file_content') %>
<% end %>
<%= (@data['extra_text'] rescue "").to_s.html_safe %>

View File

@ -6,3 +6,4 @@
<% else %>
<%= t('seminar.email_edit_file_content') %>
<% end %>
<%= (@data['extra_text'] rescue "").to_s.html_safe %>

View File

@ -0,0 +1,47 @@
<style>
.signup_infos td:first-child {
white-space: nowrap;
}
</style>
<%
data2 = @seminar.seminar_submission_field_sets.select{|v| v.field_name=='description'}[0]
show2 = !(data2.disabled) rescue false
name2 = data2['name'][I18n.locale]
description = ""
if show2
description = @con.description.to_s
if @seminar.enable_summary_choice
if (@con.description.to_s.to_i.to_s == @con.description)
description = @seminar.summary_chioices[@con.description.to_i] rescue @con.description
else
description = @con.description.map{|i| @seminar.summary_chioices[i.to_i] rescue "" }.join("<br>") rescue @con.description
end
end
end
seminar_submission_fields = @seminar.seminar_submission_fields.where(:disabled=>false)
%>
<h3><%= @seminar.title rescue nil %></h3>
<table id="signup_infos">
<tbody>
<tr>
<td>
<%= I18n.t('seminar_signup.file_name') %>:&nbsp;
</td>
<td>
<a href="<%= @host_url %><%= @con.file.url %>" target="_blank" download="<%= @con.disp_filename %>"><%= @con.disp_filename %></a>
</td>
</tr>
<% if show2 %>
<tr>
<td><%= name2.present? ? "#{name2}:" : '' %>&nbsp;</td>
<td><%= description.html_safe %></td>
</tr>
<% end %>
<% seminar_submission_fields.each do |sf| %>
<tr>
<td><%= sf.title.present? ? "#{sf.title}:" : '' %>&nbsp;</td>
<td><%= sf.seminar_submission_values.where(:seminar_signup_contribute_id=>@con.id).first.get_value_by_locale(I18n.locale) rescue "" %></td>
</tr>
<% end %>
</tbody>
</table>

View File

@ -54,7 +54,10 @@
@seminar_signup.seminar_signup_contributes.each do |seminar_signup_contribute|
%>
<tr>
<% if show1 %>
<td><%= seminar_signup_contribute.title %></td>
<% end %>
<% if show2 %>
<% description = seminar_signup_contribute.description.to_s %>
<% if @seminar.enable_summary_choice
if (seminar_signup_contribute.description.to_s.to_i.to_s == seminar_signup_contribute.description)
@ -64,7 +67,10 @@
end
end %>
<td><%= description.html_safe %></td>
<td><%= link_to File.basename(seminar_signup_contribute.file.path), seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(description.gsub("<br>"," , ")).text} if seminar_signup_contribute.file.file %></td>
<% end %>
<% if show3 %>
<td><%= link_to seminar_signup_contribute.disp_filename, seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(description.gsub("<br>"," , ")).text, :download=>seminar_signup_contribute.disp_filename} if seminar_signup_contribute.file.file %></td>
<% end %>
<% if seminar_submission_field %>
<td><%= seminar_signup_contribute.seminar_submission_values.where(:seminar_submission_field=>seminar_submission_field).first.get_value_by_locale(I18n.locale) %></td>
<% end %>