Created a new payment admin page

This commit is contained in:
Godwin
2016-08-14 00:38:10 -07:00
parent 070a292c2b
commit 2f375f7ff2
13 changed files with 781 additions and 481 deletions
+151 -2
View File
@@ -109,6 +109,21 @@ table, .table {
background-color: transparent;
border: 0;
}
&.state {
background-size: 1.333em;
background-repeat: no-repeat;
background-position: center;
width: 1.75em;
&.happy {
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 87.8 73.2'><polygon fill='#{$colour-5}' points='34.3 73.2 0 32.6 18.7 16.8 35.4 36.5 70.1 0 87.8 16.8 '/></svg>");
}
&.unhappy {
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path xmlns="http://www.w3.org/2000/svg" d="M50 5C25.1 5 5 25.1 5 50c0 24.9 20.1 45 45 45s45-20.1 45-45C95 25.1 74.9 5 50 5zM72.5 64.3l-8.2 8.2L50 58.2 35.7 72.5l-8.2-8.2L41.8 50 27.5 35.7l8.2-8.2L50 41.8l14.3-14.3 8.2 8.2L58.2 50 72.5 64.3z" fill="#{$colour-4}"/></svg>');
}
}
}
th, .table-th {
@@ -120,6 +135,39 @@ table, .table {
}
}
td, .table-td {
&.inner-table {
padding: 0;
table {
margin: 0;
width: 100%;
}
tr:first-child {
td, th {
border-top: 0;
}
}
tr:last-child {
td, th {
border-bottom: 0;
}
}
td, th {
&:first-child {
border-left: 0
}
&:last-child {
border-right: 0
}
}
}
}
tbody th {
width: 0.1rem;
}
@@ -281,6 +329,10 @@ textarea, .textarea {
&:hover, &:focus, &:active {
@include _(box-shadow, 0 0 0 0.3em rgba(0,0,0,0.05));
}
&.short {
min-height: 10em;
}
}
.textarea, .workshop-description {
@@ -1437,6 +1489,92 @@ ul.warnings li,
}
}
#admin-housing {
.host-table {
tr.place-guest {
td {
background-color: lighten($colour-1, 40%);
&:hover {
background-color: $colour-1;
}
}
a {
display: block;
color: $white;
text-align: center;
@include font-family(secondary);
@include after {
display: none;
}
}
}
button, .button {
float: right;
}
td {
vertical-align: top;
}
.state {
position: relative;
font-family: inherit;
&.unhappy {
cursor: pointer;
}
ul {
display: none;
position: absolute;
right: 100%;
top: 0;
background-color: $white;
border: 0.1em solid #CCC;
padding: 0.25em 0.75em;
margin: 0;
list-style: none;
@include default-box-shadow(top, 2);
}
li {
margin: 0;
}
&:hover {
ul {
display: block;
}
}
}
}
#guest-selector {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: rgba($black, 0.5);
.guest-dlg {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: $white;
width: 80%;
max-width: 25em;
@include default-box-shadow(top, 2);
}
}
}
#admin-housing {
#hosts {
background-color: $white;
@@ -2407,7 +2545,7 @@ html :focus {
padding: 0.5em 1.5em;
}
#main .three-options {
#main .graded-options {
text-align: center;
button {
@@ -2416,7 +2554,7 @@ html :focus {
font-size: 1.5em;
margin: 0.25em;
&:first-child {
&.option-1 {
background-color: $colour-3;
}
@@ -2424,6 +2562,17 @@ html :focus {
background-color: $colour-5;
}
}
&.option-count-4 button.option-3,
&.option-count-5 button.option-4 {
background-color: mix($colour-3, $colour-5);
}
&.option-count-5 {
button.option-2 {
background-color: mix($colour-3, $colour-4);
}
}
}
#main .skip {
+41 -18
View File
@@ -268,7 +268,7 @@ class ConferencesController < ApplicationController
@page_title = 'articles.conference_registration.headings.Policy_Agreement'
when :administration
@warnings << flash[:error] if flash[:error].present?
@admin_step = params[:admin_step] || 'edit'
@admin_step = params[:admin_step] || view_context.admin_steps.first.to_s
return do_404 unless view_context.valid_admin_steps.include?(@admin_step.to_sym)
@page_title = 'articles.conference_registration.headings.Administration'
@@ -383,7 +383,7 @@ class ConferencesController < ApplicationController
name: user.firstname || '',
email: user.email || '',
status: (view_context._"articles.conference_registration.terms.registration_status.#{(steps.include? 'questions') ? 'registered' : ((steps.include? 'contact_info') ? 'preregistered' : 'unregistered')}"),
date: r.created_at,# ? r.created_at.strftime("%F %T") : '',
date: r.created_at ? r.created_at.strftime("%F %T") : '',
city: r.city || '',
preferred_language: user.locale.present? ? (view_context.language_name user.locale) : '',
languages: ((r.languages || []).map { |x| view_context.language_name x }).join(', ').to_s,
@@ -462,7 +462,7 @@ class ConferencesController < ApplicationController
ConferenceRegistration.where(:conference_id => @this_conference.id).each do | registration |
if registration.can_provide_housing
@hosts[registration.id] = registration
else
elsif registration.housing.present? && registration.housing != 'none'
@guests[registration.id] = registration
end
end
@@ -515,6 +515,14 @@ class ConferencesController < ApplicationController
@housing_data[host_id][:warnings][:space][space] << :overbooked
end
@housing_data[host_id][:guest_data] ||= {}
@housing_data[host_id][:guest_data][guest_id] = { warnings: {}, errors: {} }
if (guest.housing == 'house' && space == :tent) ||
(guest.housing == 'tent' && (space == :bed_space || space == :floor_space))
@housing_data[host_id][:guest_data][guest_id][:warnings][:space] = { actual: space.to_s, expected: guest.housing}
end
companions = data['companions'] || []
companions.each do | companion |
user = User.find_by_email(companion)
@@ -523,16 +531,17 @@ class ConferencesController < ApplicationController
:user_id => user.id,
:conference_id => @this_conference.id
)
housing_data = reg.housing_data || {}
companion_host = housing_data['host'].present? ? housing_data['host'].to_i : nil
if companion_host.blank?
@hosts_affected_by_guests[guest_id] << companion_host
if companion_host != host_id
# set this as an error if the guest has selected only one other to stay with, but if they have requested to stay with more, make this only a warning
status = companions.size > 1 ? :warnings : :errors
@housing_data[host_id][:guests][guest][status] ||= {}
@housing_data[host_id][:guests][guest][status][:companions] ||= []
@housing_data[host_id][:guests][guest][status][:companions] << reg.id
if reg.present? && @guests[reg.id].present?
housing_data = reg.housing_data || {}
companion_host = housing_data['host'].present? ? housing_data['host'].to_i : nil
if companion_host.blank?
@hosts_affected_by_guests[guest_id] << companion_host
if companion_host != host_id && reg.housing.present? && reg.housing != 'none'
# set this as an error if the guest has selected only one other to stay with, but if they have requested to stay with more, make this only a warning
status = companions.size > 1 ? :warnings : :errors
@housing_data[host_id][:guest_data][guest_id][status][:companions] ||= []
@housing_data[host_id][:guest_data][guest_id][status][:companions] << { name: reg.user.name, id: reg.id }
end
end
end
end
@@ -568,12 +577,8 @@ class ConferencesController < ApplicationController
params[:info_translations].each do | locale, value |
@this_conference.set_column_for_locale(:info, locale, value, current_user.id) unless value == @this_conference._info(locale)
end
@this_conference.paypal_email_address = params[:paypal_email_address]
@this_conference.paypal_username = params[:paypal_username]
@this_conference.paypal_password = params[:paypal_password]
@this_conference.paypal_signature = params[:paypal_signature]
@this_conference.save
return redirect_to register_step_path(@this_conference.slug, :administration)
return redirect_to administration_step_path(@this_conference.slug, :edit)
when 'add_member'
org = nil
@this_conference.organizations.each do | organization |
@@ -583,6 +588,24 @@ class ConferencesController < ApplicationController
org.save
return redirect_to administration_step_path(@this_conference.slug, :edit)
end
when 'payment'
case params[:button]
when 'save'
@this_conference.payment_message = LinguaFranca::ActiveRecord::UntranslatedValue.new(params[:payment_message]) unless @this_conference.payment_message! == params[:payment_message]
params[:payment_message_translations].each do | locale, value |
@this_conference.set_column_for_locale(:payment_message, locale, value, current_user.id) unless value == @this_conference._payment_message(locale)
end
@this_conference.payment_amounts = ((params[:payment_amounts] || {}).values.map &:to_i) - [0]
@this_conference.paypal_email_address = params[:paypal_email_address]
@this_conference.paypal_username = params[:paypal_username]
@this_conference.paypal_password = params[:paypal_password]
@this_conference.paypal_signature = params[:paypal_signature]
@this_conference.save
return redirect_to administration_step_path(@this_conference.slug, :payment)
end
when 'housing'
space = params[:button].split(':')[0]
host_id = params[:button].split(':')[1].to_i
+85 -4
View File
@@ -957,7 +957,7 @@ module ApplicationHelper
end
def admin_steps
[:edit, :stats, :broadcast, :housing, :locations, :meals, :events, :workshop_times, :schedule]
[:stats, :edit, :payment, :broadcast, :housing, :locations, :meals, :events, :workshop_times, :schedule]
end
def valid_admin_steps
@@ -991,6 +991,81 @@ module ApplicationHelper
return _'articles.workshops.info.interested_count', :vars => {:count => workshop.interested_count}
end
def host_guests_table(registration)
id = registration.id
html = ''
@housing_data[id][:guests].each do | area, guests |
guest_rows = ''
guests.each do | guest_id, guest |
status_html = ''
@housing_data[id][:guest_data][guest_id][:errors].each do | error, value |
if value.is_a?(Array)
value.each do | v |
status_html += _("errors.housing.space.#{error.to_s}", vars: {value: v})
end
else
status_html += _("errors.housing.space.#{error.to_s}", vars: {value: value })
end
end
@housing_data[id][:guest_data][guest_id][:warnings].each do | error, value |
if value.is_a?(Array)
value.each do | v |
status_html += _("warnings.housing.space.#{error.to_s}", v)
end
else
status_html += _("warnings.housing.space.#{error.to_s}", vars: value)
end
end
if status_html.present?
status_html = content_tag(:ul, status_html.html_safe)
end
guest_rows += content_tag :tr, id: "hosted-guest-#{guest_id}" do
(content_tag :td, guest[:guest].user.name) +
(content_tag :td do
(guest[:guest].city +
(button_tag :remove, class: [:small, :delete])).html_safe
end) +
(content_tag :td, status_html.html_safe, class: [:state, status_html.present? ? :unhappy : :happy])
end
for i in guests.size..(@housing_data[id][:space][area] || 0)
guest_rows += content_tag :tr, class: 'empty-space' do
(content_tag :td, '', colspan: 2) +
(content_tag :td)
end
end
end
status_html = ''
if @housing_data[id][:warnings].present? && @housing_data[id][:warnings][:space].present? && @housing_data[id][:warnings][:space][area].present?
@housing_data[id][:warnings][:space][area].each do | w |
status_html += content_tag(:li, _("warnings.housing.space.#{w.to_s}"))
end
end
if status_html.present?
status_html = content_tag(:ul, status_html.html_safe)
end
html += content_tag :tr do
(content_tag :th, (_"forms.labels.generic.#{area}"), colspan: 2) +
(content_tag :th, status_html.html_safe, class: [:state, status_html.present? ? :unhappy : :happy])
end
html += guest_rows
html += content_tag :tr, class: 'place-guest' do
content_tag :td, colspan: 3 do
content_tag :a, (_'forms.actions.generic.place_guest'), class: 'select-guest', href: '#', data: { host: id, space: area }
end
end
end
content_tag :table, html.html_safe, class: 'host-table'
end
def host_guests_widget(registration)
html = ''
classes = ['host']
@@ -1102,19 +1177,25 @@ module ApplicationHelper
aria = {}
aria[:labelledby] = label_id if label_id.present?
aria[:describedby] = description_id if description_id.present?
css_class = [
options[:short] === true ? :short : nil
].compact
if options[:plain]
html += (text_area_tag name, value,
id: id,
lang: options[:lang],
aria: aria)
aria: aria,
class: css_class
)
else
html += content_tag(:div, value.present? ? value.html_safe : '',
id: id,
class: 'textarea',
data: { name: name, 'edit-on': options[:edit_on] || :load },
lang: options[:lang],
aria: aria,
tabindex: 0
tabindex: 0,
class: [:textarea] + css_class
)
add_stylesheet :editor
+5 -1
View File
@@ -1,5 +1,5 @@
class Conference < ActiveRecord::Base
translates :info, :title
translates :info, :title, :payment_message
mount_uploader :cover, CoverUploader
mount_uploader :poster, PosterUploader
@@ -64,4 +64,8 @@ class Conference < ActiveRecord::Base
write_attribute :registration_status, new_registration_status.to_s
end
def self.default_payment_amounts
[25, 50, 100]
end
end
+16 -15
View File
@@ -1,28 +1,29 @@
= columns(medium: 12) do
- if @registration.registration_fees_paid.present?
%p
%strong=_'articles.conference_registration.paragraphs.Payment_Made', :p, vars: { fees_paid: @registration.registration_fees_paid }
%strong=_'articles.conference_registration.paragraphs.Payment_Made', :p, vars: { fees_paid: (number_to_currency @registration.registration_fees_paid, unit: '$') }
= _'articles.conference_registration.paragraphs.Payment_Add'
= @this_conference.payment_message.html_safe if @this_conference.payment_message.present?
- elsif @this_conference.payment_message.present?
= @this_conference.payment_message.html_safe
- else
%p=_'articles.conference_registration.paragraphs.Payment', :p
%p=@this_conference.payment_message || (_'articles.conference_registration.paragraphs.Payment', :p)
= columns(large: 9, push: 1) do
= form_tag register_path(@this_conference.slug), :class => :payment do
= form_tag register_path(@this_conference.slug), class: :payment do
= hidden_field_tag :button, :payment
.three-options
= button_tag :amount_25, :name => :amount, :value => '25.0' do
=_! '$25.00'
= button_tag :amount_50, :name => :amount, :value => '50.0' do
=_! '$50.00'
= button_tag :amount_100, :name => :amount, :value => '100.0' do
= _!'$100.00'
= form_tag register_path(@this_conference.slug), :class => ['custom-payment', :centered] do
- payment_amounts = @this_conference.payment_amounts.present? ? @this_conference.payment_amounts : Conference.default_payment_amounts
.graded-options{class: "option-count-#{payment_amounts.size}"}
- payment_amounts.each_with_index do | amount, i |
= button_tag :amount_25, name: :amount, value: amount.to_f.to_s, class: "option-#{i + 1}" do
=_! (number_to_currency amount, unit: '$')
= form_tag register_path(@this_conference.slug), class: ['custom-payment', :centered] do
%span.currency=_!'$'
= numberfield :amount, nil, :required => true, :step => 0.01, :min => 0.00, label: false
= button_tag :custom_amount, :value => :payment
= numberfield :amount, nil, required: true, step: 0.01, min: 0.00, label: false
= button_tag :custom_amount, value: :payment
%p=_'articles.conference_registration.paragraphs.currency','(amounts are in $USD)'
= form_tag register_path(@this_conference.slug), :class => :payment do
= form_tag register_path(@this_conference.slug), class: :payment do
= hidden_field_tag :button, :payment
.actions.skip
= button_tag :skip, :name => :amount, :value => '0.0'
= button_tag :skip, name: :amount, value: '0.0'
= columns(large: 2)
@@ -1 +0,0 @@
%p= _'articles.conference_registration.paragraphs.admin.broadcast.sent'
@@ -4,12 +4,6 @@
- I18n.backend.enabled_locales.each do | locale |
- if locale.to_s != @this_conference.locale.to_s
= textarea "info_translations[#{locale.to_s}]", @this_conference._info(locale), label: 'translate.pages.Locale_Translation', vars: { language: _("languages.#{locale}") }, lang: locale, edit_on: :focus
%h4=_'articles.admin.edit.headings.paypal_info', :t
%p=(_'articles.admin.edit.paragraphs.paypal_info', :p).html_safe
= emailfield :paypal_email_address, @this_conference.paypal_email_address || @this_conference.email_address || (@this_conference.organizations.present? && @this_conference.organizations.first.present? ? @this_conference.organizations.first.email_address : nil)
= textfield :paypal_username, @this_conference.paypal_username
= passwordfield :paypal_password, @this_conference.paypal_password
= textfield :paypal_signature, @this_conference.paypal_signature
.actions.right
= button_tag :save, value: :save
%h4=_'articles.admin.edit.headings.host_organizations'
@@ -0,0 +1,20 @@
= form_tag administration_update_path(@this_conference.slug, :payment) do
= textarea :payment_message, (@this_conference.payment_message! || "<p>#{I18n.t('articles.conference_registration.paragraphs.Payment', locale: @this_conference.locale)}</p>"), help: 'articles.conference_registration.paragraphs.admin.payment.message', lang: @this_conference.locale, edit_on: :focus, short: true
- I18n.backend.enabled_locales.each do | locale |
- if locale.to_s != @this_conference.locale.to_s
= textarea "payment_message_translations[#{locale.to_s}]", (@this_conference._payment_message(locale) || "<p>#{I18n.t('articles.conference_registration.paragraphs.Payment', locale: locale)}</p>"), label: 'translate.pages.Locale_Translation', vars: { language: _("languages.#{locale}") }, lang: locale, edit_on: :focus, short: true
%h4=_'articles.admin.payment.headings.payment_amounts', :t
= fieldset :payment_amounts, help: 'articles.admin.payment.paragraphs.payment_amounts' do
- payment_amounts = @this_conference.payment_amounts.present? ? @this_conference.payment_amounts : Conference.default_payment_amounts
- for i in 1..5 do
= numberfield "payment_amounts[#{i - 1}]", payment_amounts[i - 1], step: 0.01, min: 0.00, label: false
%h4=_'articles.admin.edit.headings.paypal_info', :t
%p=(_'articles.admin.edit.paragraphs.paypal_info', :p).html_safe
= emailfield :paypal_email_address, @this_conference.paypal_email_address || @this_conference.email_address || (@this_conference.organizations.present? && @this_conference.organizations.first.present? ? @this_conference.organizations.first.email_address : nil)
= textfield :paypal_username, @this_conference.paypal_username
= passwordfield :paypal_password, @this_conference.paypal_password
= textfield :paypal_signature, @this_conference.paypal_signature
.actions.right
= button_tag :save, value: :save