Added localization to workshops, made login persist through subdomains

This commit is contained in:
Godwin
2015-09-14 21:16:22 -07:00
parent a63b5e1dc2
commit 01d8679c9d
73 changed files with 1840 additions and 187 deletions
+17
View File
@@ -539,6 +539,10 @@ form {
font-weight: bold;
font-size: 1.25em;
}
.left {
float: left;
}
}
}
@@ -1889,3 +1893,16 @@ html[data-lingua-franca-example="html"] {
margin-left: 1em;
}
}
.original-text {
margin: 0 0 1em 1em;
h4 {
margin: 0;
}
.value {
margin-left: 1em;
}
p {
font-size: 1.1em;
}
}
+22 -12
View File
@@ -823,7 +823,8 @@ class ConferencesController < ApplicationController
set_conference_registration
@workshop = Workshop.find_by_id_and_conference_id(params[:workshop_id], @this_conference.id)
do_404 unless @workshop
do_403 unless @workshop.can_edit?(current_user)
@can_edit = @workshop.can_edit?(current_user)
do_403 unless @can_edit || @workshop.can_translate?(current_user)
@title = @workshop.title
@info = @workshop.info
@needs = JSON.parse(@workshop.needs || '[]').map &:to_sym
@@ -869,20 +870,29 @@ class ConferencesController < ApplicationController
def save_workshop
set_conference
set_conference_registration
if params[:workshop_id]
workshop = Workshop.find(params[:workshop_id])
do_404 unless workshop
else
workshop = Workshop.new(:conference_id => @this_conference.id)
workshop.workshop_facilitators = [WorkshopFacilitator.new(:user_id => current_user.id, :role => :creator)]
end
can_edit = workshop.can_edit?(current_user)
do_403 unless can_edit || workshop.can_translate?(current_user)
workshop.title = params[:title]
workshop.info = params[:info]
workshop.languages = (params[:languages] || {}).keys.to_json
workshop.needs = (params[:needs] || {}).keys.to_json
workshop.theme = params[:theme] == 'other' ? params[:other_theme] : params[:theme]
workshop.space = params[:space]
workshop.notes = params[:notes]
if can_edit
# dont allow translators to edit these fields
workshop.languages = (params[:languages] || {}).keys.to_json
workshop.needs = (params[:needs] || {}).keys.to_json
workshop.theme = params[:theme] == 'other' ? params[:other_theme] : params[:theme]
workshop.space = params[:space]
workshop.notes = params[:notes]
end
workshop.save
redirect_to view_workshop_url(@this_conference.slug, workshop.id)
@@ -920,16 +930,16 @@ class ConferencesController < ApplicationController
def set_conference_registration
@registration = logged_in? ? ConferenceRegistration.find_by(:user_id => current_user.id, :conference_id => @this_conference.id) : nil
@is_host = @conference.host?(current_user)
@is_host = @this_conference.host?(current_user)
if @registration || @is_host
@submenu = {
register_path(@conference.slug) => 'registration.Registration',
workshops_path(@conference.slug) => 'registration.Workshops'
register_path(@this_conference.slug) => 'registration.Registration',
workshops_path(@this_conference.slug) => 'registration.Workshops'
}
if @is_host
@submenu[edit_conference_path(@conference.slug)] = 'registration.Edit'
@submenu[stats_path(@conference.slug)] = 'registration.Stats'
@submenu[broadcast_path(@conference.slug)] = 'registration.Broadcast'
@submenu[edit_conference_path(@this_conference.slug)] = 'registration.Edit'
@submenu[stats_path(@this_conference.slug)] = 'registration.Stats'
@submenu[broadcast_path(@this_conference.slug)] = 'registration.Broadcast'
end
end
end
+6
View File
@@ -1,4 +1,6 @@
class Workshop < ActiveRecord::Base
translates :info, :title
belongs_to :conference
has_many :workshop_facilitators, :dependent => :destroy
@@ -48,6 +50,10 @@ class Workshop < ActiveRecord::Base
workshops ? workshops.size : 0
end
def can_translate?(user)
user.can_translate? || can_edit?(user)
end
private
def make_slug
if !self.slug
+4
View File
@@ -7,6 +7,10 @@
= label_tag :info
= text_area_tag :info, @this_conference.info, :required => true
.actions.right
.left
- I18n.backend.enabled_locales.each do |locale|
= (link_to (_'actions.conference.Translate', "Edit #{language_name(locale)} version", :vars => {:language => language_name(locale)}), edit_conference_path(@this_conference.slug, url_params(locale)), :class => 'translate') if locale.to_sym != I18n.locale.to_sym
= button_tag :save, :value => :save
:javascript
+1 -1
View File
@@ -18,7 +18,7 @@
%ul
-I18n.backend.enabled_locales.each do |locale|
%li
%a{href: request.original_url.gsub(/^(https?:\/\/)(preview\-)?(..\.)?(.*)$/, '\1\2' + locale + '.\4')}
%a{href: home_url(url_params(locale))}
=_! locale.upcase
%span=I18n.t("languages.#{locale}", locale: locale, context: I18n.t("languages.#{locale}"))
.copy
+2 -2
View File
@@ -9,11 +9,11 @@
= nav_link about_path, (_'page_titles.About_BikeBike')
= nav_link policy_path, (_'page_titles.Safe_Space_Policy')
.actions
- if @conference.registration_open
- if @conference && @conference.registration_open
- if params[:action] != 'register' && !@registration
= link_to register_path(@conference.slug), class: [:button, :register] do
=_'conference.actions.Register'
- else
- elsif @conference
= render 'shared/donate_button', :email_address => (@conference.paypal_email_address || @conference.email_address)
- if current_user
= form_tag :logout, class: :logout do
+52 -43
View File
@@ -8,52 +8,61 @@
.text-field.input-field.big
= label_tag :title
= text_field_tag :title, @title, :required => true
- if @workshop && I18n.locale.to_s != @workshop.locale.to_s
.original-text
%h4=_'translate.content.Translation_of'
.value=@workshop.title!
.text-area-field.input-field
= label_tag :info
= text_area_tag :info, @info, :required => true
= columns(medium: 6) do
%h3=_'articles.workshops.headings.languages','Workshop Language'
- [:en, :es, :fr].each do |language|
.single-check-box-field.input-field
= label_tag "languages_#{language}" do
= check_box_tag "languages[#{language}]", 1, @languages && @languages.include?(language)
= _"languages.#{language}"
%h3=_'articles.workshops.headings.theme','Theme'
.input-field-help=_'articles.workshops.paragraphs.theme', :p
- theme_found = false
- [:race_gender, :mechanics, :funding, :organization, :community].each do |theme|
.single-radio-button-field.input-field
= label_tag "theme_#{theme}" do
- is_selected = (@theme == theme)
- theme_found ||= is_selected
= radio_button_tag :theme, theme, is_selected
= _"workshop.options.theme.#{theme}"
.single-radio-button-field.other-field.input-field
= label_tag "theme_other" do
= radio_button_tag :theme, :other, (@theme && !theme_found)
%div
= _"workshop.options.theme.other"
= text_field_tag :other_theme, (@theme && !theme_found ? @theme : nil)
= columns(medium: 6) do
%h3=_'articles.workshops.headings.needs','What do you need?'
- [:sound, :projector, :tools].each do |need|
.single-check-box-field.input-field
= label_tag "needs_#{need}" do
= check_box_tag "needs[#{need}]", 1, @needs.include?(need)
= _"workshop.options.needs.#{need}"
%h3=_'articles.workshops.headings.space','Type of space'
.input-field-help=_'articles.workshops.paragraphs.space', :p
- [:meeting_room, :workshop, :outdoor_meeting].each do |space|
.single-radio-button-field.input-field
= label_tag "space_#{space}" do
= radio_button_tag :space, space, @space == space
= _"workshop.options.space.#{space}"
= columns(medium: 12) do
%h3=_'articles.workshops.headings.notes','Notes for Conference Organizers and Workshop Facilitators'
%p=_'articles.workshops.paragraphs.notes','Notes are only viewable by conference hosts and workshop facilitators'
.text-area-field.input-field
= label_tag :notes
= text_area_tag :notes, @notes
- if @workshop && I18n.locale.to_s != @workshop.locale.to_s
.original-text
%h4=_'translate.content.Translation_of'
.value=markdown @workshop.info!
- if !@workshop || @can_edit
= columns(medium: 6) do
%h3=_'articles.workshops.headings.languages','Workshop Language'
- [:en, :es, :fr].each do |language|
.single-check-box-field.input-field
= label_tag "languages_#{language}" do
= check_box_tag "languages[#{language}]", 1, @languages && @languages.include?(language)
= _"languages.#{language}"
%h3=_'articles.workshops.headings.theme','Theme'
.input-field-help=_'articles.workshops.paragraphs.theme', :p
- theme_found = false
- [:race_gender, :mechanics, :funding, :organization, :community].each do |theme|
.single-radio-button-field.input-field
= label_tag "theme_#{theme}" do
- is_selected = (@theme == theme)
- theme_found ||= is_selected
= radio_button_tag :theme, theme, is_selected
= _"workshop.options.theme.#{theme}"
.single-radio-button-field.other-field.input-field
= label_tag "theme_other" do
= radio_button_tag :theme, :other, (@theme && !theme_found)
%div
= _"workshop.options.theme.other"
= text_field_tag :other_theme, (@theme && !theme_found ? @theme : nil)
= columns(medium: 6) do
%h3=_'articles.workshops.headings.needs','What do you need?'
- [:sound, :projector, :tools].each do |need|
.single-check-box-field.input-field
= label_tag "needs_#{need}" do
= check_box_tag "needs[#{need}]", 1, @needs.include?(need)
= _"workshop.options.needs.#{need}"
%h3=_'articles.workshops.headings.space','Type of space'
.input-field-help=_'articles.workshops.paragraphs.space', :p
- [:meeting_room, :workshop, :outdoor_meeting].each do |space|
.single-radio-button-field.input-field
= label_tag "space_#{space}" do
= radio_button_tag :space, space, @space == space
= _"workshop.options.space.#{space}"
= columns(medium: 12) do
%h3=_'articles.workshops.headings.notes','Notes for Conference Organizers and Workshop Facilitators'
%p=_'articles.workshops.paragraphs.notes','Notes are only viewable by conference hosts and workshop facilitators'
.text-area-field.input-field
= label_tag :notes
= text_area_tag :notes, @notes
= columns(medium: 12) do
.actions.right
= button_tag :save, :value => :save
+3
View File
@@ -40,4 +40,7 @@
= columns(medium: 12) do
.actions
= (link_to (_'actions.workshops.Edit'), edit_workshop_path(@this_conference.slug, @workshop.id), :class => 'button modify') if @workshop.can_edit?(current_user)
- if @workshop.can_translate?(current_user)
- I18n.backend.enabled_locales.each do |locale|
= (link_to (_'actions.workshops.Translate', "Translate into #{language_name(locale)}", :vars => {:language => language_name(locale)}), edit_workshop_url(@this_conference.slug, @workshop.id, url_params(locale)), :class => 'button translate') if locale.to_sym != I18n.locale.to_sym
= (link_to (_'actions.workshops.Delete'), delete_workshop_path(@this_conference.slug, @workshop.id), :class => 'button delete') if @workshop.can_delete?(current_user)