From 8369fef112648bc23a04ba02da65050ddbee953c Mon Sep 17 00:00:00 2001 From: Jan Schulz-Hofen Date: Fri, 14 Oct 2016 15:28:27 +0200 Subject: [PATCH 3/3] Adds registration CTA links to relevant places --- app/helpers/application_helper.rb | 6 ++++++ app/views/account/login.html.erb | 4 ++++ app/views/issues/index.html.erb | 6 +++++- app/views/issues/show.html.erb | 5 +++++ app/views/messages/show.html.erb | 8 +++++++- app/views/news/show.html.erb | 8 +++++++- app/views/settings/_authentication.html.erb | 8 +++++++- config/locales/de.yml | 8 ++++++++ config/locales/en.yml | 8 ++++++++ config/settings.yml | 2 ++ public/stylesheets/application.css | 1 + 11 files changed, 60 insertions(+), 4 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e6fd4eb..035d12a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1268,6 +1268,12 @@ module ApplicationHelper content_for?(:sidebar) || view_layouts_base_sidebar_hook_response.present? end + def show_registration_cta?(action=nil, context=nil, options={}) + return false if User.current.logged? or !Setting.self_registration? or !Setting.enable_registration_cta? + return true if action.blank? and context.blank? and options.blank? + return User.new.allowed_to?(action, context, options) + end + def view_layouts_base_sidebar_hook_response @view_layouts_base_sidebar_hook_response ||= call_hook(:view_layouts_base_sidebar) end diff --git a/app/views/account/login.html.erb b/app/views/account/login.html.erb index 1440e32..c66842f 100644 --- a/app/views/account/login.html.erb +++ b/app/views/account/login.html.erb @@ -24,6 +24,10 @@ <% end %> + + <% if show_registration_cta? %> +

<%= l(:text_no_account_question)%> <%= link_to l(:label_register), :register %>

+ <% end %> <%= call_hook :view_account_login_bottom %> diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb index d0fd943..1915172 100644 --- a/app/views/issues/index.html.erb +++ b/app/views/issues/index.html.erb @@ -1,5 +1,5 @@
- <% if User.current.allowed_to?(:add_issues, @project, :global => true) && (@project.nil? || Issue.allowed_target_trackers(@project).any?) %> + <% if allowed_to_add_issues = (User.current.allowed_to?(:add_issues, @project, :global => true) && (@project.nil? || Issue.allowed_target_trackers(@project).any?)) %> <%= link_to l(:label_issue_new), _new_project_issue_path(@project), :class => 'icon icon-add new-issue' %> <% end %>
@@ -53,6 +53,10 @@ <% end %> <%= call_hook(:view_issues_index_bottom, { :issues => @issues, :project => @project, :query => @query }) %> +<% if !allowed_to_add_issues && show_registration_cta?(:add_issues, @project, :global => true) %> +

<%= t :label_register_to_add_issue_html, register_to: link_to(l(:label_register_to), register_path) %>

+<% end %> + <% content_for :sidebar do %> <%= render :partial => 'issues/sidebar' %> <% end %> diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb index f884905..9382ee4 100644 --- a/app/views/issues/show.html.erb +++ b/app/views/issues/show.html.erb @@ -123,6 +123,11 @@ end %> <% end %> +<% if !@issue.editable? && show_registration_cta? && + (User.new.allowed_to?(:edit_issues, @project) || User.new.allowed_to?(:add_issue_notes, @project)) %> + +

<%= t :label_register_to_edit_issue_html, register_to: link_to(l(:label_register_to), register_path) %>

+<% end %>
<%= render :partial => 'action_menu' %> diff --git a/app/views/messages/show.html.erb b/app/views/messages/show.html.erb index 0911bd4..844c214 100644 --- a/app/views/messages/show.html.erb +++ b/app/views/messages/show.html.erb @@ -35,8 +35,12 @@ <% unless @replies.empty? %>

<%= l(:label_reply_plural) %> (<%= @reply_count %>)

-<% if !@topic.locked? && authorize_for('messages', 'reply') && @replies.size >= 3 %> +<% if @replies.size >= 3 %> +<% if !@topic.locked? && authorize_for('messages', 'reply') %>

<%= toggle_link l(:button_reply), "reply", :focus => 'message_content', :scroll => "message_content" %>

+<% elsif show_registration_cta? :add_messages, @project %> +

<%= t :label_register_to_add_message_html, register_to: link_to(l(:label_register_to), register_path) %>

+<% end %> <% end %> <% @replies.each do |message| %>
"> @@ -87,6 +91,8 @@ <% end %>
+<% elsif show_registration_cta? :add_messages, @project %> +

<%= t :label_register_to_add_message_html, register_to: link_to(l(:label_register_to), register_path) %>

<% end %> <% html_title @topic.subject %> diff --git a/app/views/news/show.html.erb b/app/views/news/show.html.erb index 09e14f6..f62e478 100644 --- a/app/views/news/show.html.erb +++ b/app/views/news/show.html.erb @@ -33,8 +33,12 @@

<%= l(:label_comment_plural) %>

-<% if @news.commentable? && @comments.size >= 3 %> +<% if @comments.size >= 3 %> +<% if @news.commentable? %>

<%= toggle_link l(:label_comment_add), "add_comment_form", :focus => "comment_comments", :scroll => "comment_comments" %>

+<% elsif show_registration_cta? :comment_news, @project %> +

<%= t :label_register_to_comment_html, register_to: link_to(l(:label_register_to), register_path) %>

+<% end %> <% end %> <% @comments.each do |comment| %> <% next if comment.new_record? %> @@ -60,6 +64,8 @@

<%= submit_tag l(:button_add) %>

<% end %> +<% elsif show_registration_cta? :comment_news, @project %> +

<%= t :label_register_to_comment_html, register_to: link_to(l(:label_register_to), register_path) %>

<% end %> <% html_title @news.title -%> diff --git a/app/views/settings/_authentication.html.erb b/app/views/settings/_authentication.html.erb index 4eda969..de9843e 100644 --- a/app/views/settings/_authentication.html.erb +++ b/app/views/settings/_authentication.html.erb @@ -10,7 +10,13 @@ [l(:label_registration_manual_activation), "2"], [l(:label_registration_automatic_activation), "3"]], :onchange => - "if (this.value != '0') { $('#settings_show_custom_fields_on_registration').removeAttr('disabled'); } else { $('#settings_show_custom_fields_on_registration').attr('disabled', true); }" %>

+ "if (this.value != '0') { $('#settings_enable_registration_cta, #settings_show_custom_fields_on_registration').removeAttr('disabled'); } else { $('#settings_enable_registration_cta, #settings_show_custom_fields_on_registration').attr('disabled', true); }" %>

+ +

+ <%= setting_check_box :enable_registration_cta, + :disabled => !Setting.self_registration? %> + <%= l(:text_enable_registration_cta) %> +

<%= setting_check_box :show_custom_fields_on_registration, :disabled => !Setting.self_registration? %>

diff --git a/config/locales/de.yml b/config/locales/de.yml index 8781e9f..63a5205 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -697,6 +697,11 @@ de: label_read: Lesen... label_readonly: Nur-Lese-Zugriff label_register: Registrieren + label_register_to: registrieren Sie sich + label_register_to_comment_html: Bitte %{register_to}, um einen Kommentar hinzuzufügen + label_register_to_add_message_html: Bitte %{register_to}, um zu antworten + label_register_to_edit_issue_html: Bitte %{register_to}, um das Ticket zu bearbeiten + label_register_to_add_issue_html: Bitte %{register_to}, um ein Ticket hinzuzufügen label_registered_on: Angemeldet am label_registration_activation_by_email: Kontoaktivierung durch E-Mail label_registration_automatic_activation: Automatische Kontoaktivierung @@ -1039,6 +1044,7 @@ de: setting_rest_api_enabled: REST-Schnittstelle aktivieren setting_self_registration: Registrierung ermöglichen setting_show_custom_fields_on_registration: Benutzerdefinierte Felder bei der Registrierung abfragen + setting_enable_registration_cta: Aktiviere Registerungsaufforderungen setting_sequential_project_identifiers: Fortlaufende Projektkennungen generieren setting_session_lifetime: Längste Dauer einer Sitzung setting_session_timeout: Zeitüberschreitung bei Inaktivität @@ -1062,6 +1068,8 @@ de: text_assign_time_entries_to_project: Gebuchte Aufwände dem Projekt zuweisen text_caracters_maximum: "Max. %{count} Zeichen." text_caracters_minimum: "Muss mindestens %{count} Zeichen lang sein." + text_enable_registration_cta: Zeigt Links zum Registrierungsformular wo möglich + text_no_account_question: Noch kein Benutzerkonto? text_comma_separated: Mehrere Werte erlaubt (durch Komma getrennt). text_convert_available: ImageMagick-Konvertierung verfügbar (optional) text_custom_field_possible_values_info: 'Eine Zeile pro Wert' diff --git a/config/locales/en.yml b/config/locales/en.yml index 54eb127..58f5fd2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -372,6 +372,7 @@ en: setting_default_language: Default language setting_login_required: Authentication required setting_self_registration: Self-registration + setting_enable_registration_cta: Enable registration call to action setting_show_custom_fields_on_registration: Show custom fields on registration setting_attachment_max_size: Maximum attachment size setting_issues_export_limit: Issues export limit @@ -583,6 +584,11 @@ en: label_information_plural: Information label_please_login: Please log in label_register: Register + label_register_to: register + label_register_to_comment_html: Please %{register_to} to add a comment + label_register_to_add_message_html: Please %{register_to} to reply + label_register_to_edit_issue_html: Please %{register_to} to edit this issue + label_register_to_add_issue_html: Please %{register_to} to add an issue label_login_with_open_id_option: or login with OpenID label_password_lost: Lost password label_password_required: Confirm your password to continue @@ -1094,6 +1100,8 @@ en: text_length_between: "Length between %{min} and %{max} characters." text_tracker_no_workflow: No workflow defined for this tracker text_unallowed_characters: Unallowed characters + text_enable_registration_cta: Show links to registration form where possible + text_no_account_question: No account yet? text_comma_separated: Multiple values allowed (comma separated). text_line_separated: Multiple values allowed (one line for each value). text_issues_ref_in_commit_messages: Referencing and fixing issues in commit messages diff --git a/config/settings.yml b/config/settings.yml index 7f70a17..e66d5e8 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -31,6 +31,8 @@ login_required: self_registration: default: '2' security_notifications: 1 +enable_registration_cta: + default: 0 show_custom_fields_on_registration: default: 1 lost_password: diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 44100fe..63460c7 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -714,6 +714,7 @@ p.other-formats { text-align: right; font-size:0.9em; color: #666; } .other-formats span + span:before { content: "| "; } a.atom { background: url(../images/feed.png) no-repeat 1px 50%; padding: 2px 0px 3px 16px; } +p.registration-cta { background: url(../images/user.png) no-repeat 1px 50%; padding: 2px 0px 3px 20px; } em.info {font-style:normal;font-size:90%;color:#888;display:block;} em.info.error {padding-left:20px; background:url(../images/exclamation.png) no-repeat 0 50%;} -- 2.7.2