From f193116a4f38a4d3c8a9e5f7da3006a6f006448d Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Mon, 9 Feb 2015 20:00:55 -0500 Subject: Bug 1123275 - Changes to form.reps.mentorship (DRAFT) --- extensions/REMO/Extension.pm | 30 +- .../en/default/bug/create/comment-mozreps.txt.tmpl | 16 +- .../en/default/bug/create/create-mozreps.html.tmpl | 408 ++++++++++----------- .../default/bug/create/created-mozreps.html.tmpl | 19 +- extensions/REMO/web/js/moz_reps.js | 87 +++++ extensions/REMO/web/styles/moz_reps.css | 5 + 6 files changed, 339 insertions(+), 226 deletions(-) create mode 100644 extensions/REMO/web/js/moz_reps.js (limited to 'extensions') diff --git a/extensions/REMO/Extension.pm b/extensions/REMO/Extension.pm index b436d09d3..ab39a45dc 100644 --- a/extensions/REMO/Extension.pm +++ b/extensions/REMO/Extension.pm @@ -28,6 +28,7 @@ use Bugzilla::Constants; use Bugzilla::Util qw(trick_taint trim detaint_natural); use Bugzilla::Token; use Bugzilla::Error; +use List::Util qw(first); our $VERSION = '0.01'; @@ -243,9 +244,11 @@ sub post_bug_after_creation { my $bug = $vars->{bug}; my $template = Bugzilla->template; - if (Bugzilla->input_params->{format} - && Bugzilla->input_params->{format} eq 'remo-swag') - { + my $format = Bugzilla->input_params->{format}; + + return unless defined $format; + + if ($format eq 'remo-swag') { # If the attachment cannot be successfully added to the bug, # we notify the user, but we don't interrupt the bug creation process. my $error_mode_cache = Bugzilla->error_mode; @@ -304,6 +307,27 @@ sub post_bug_after_creation { Bugzilla->error_mode($error_mode_cache); } + + elsif ($format eq 'mozreps') { + my $needinfo_type = first { $_->name eq 'needinfo' } @{$bug->flag_types}; + return unless $needinfo_type; + my %original_cc = map { $_ => 1 } Bugzilla->cgi->param('cc'); + my @cc_users = grep { $_->is_enabled && $original_cc{$_->login}} @{$bug->cc_users}; + my @new_flags = map { + { type_id => $needinfo_type->id, + status => '?', + requestee => $_->login } + } @cc_users; + + $bug->set_flags(\@new_flags, []) if @new_flags; + $bug->add_comment( + join(", ", map { $_->realname || $_->login_name } @cc_users) . + ": You have been added as supporter to this Reps application, please comment why do you endorse their application. Thanks!" + ); + + $bug->update($bug->creation_ts); + Bugzilla::BugMail::Send($bug->id, { changer => Bugzilla->user }); + } } __PACKAGE__->NAME; diff --git a/extensions/REMO/template/en/default/bug/create/comment-mozreps.txt.tmpl b/extensions/REMO/template/en/default/bug/create/comment-mozreps.txt.tmpl index 95ab1c3e4..c33202c81 100644 --- a/extensions/REMO/template/en/default/bug/create/comment-mozreps.txt.tmpl +++ b/extensions/REMO/template/en/default/bug/create/comment-mozreps.txt.tmpl @@ -27,8 +27,8 @@ Last Name: Under 18 years old: [%+ IF cgi.param('underage') %]Yes[% ELSE %]No[% END %] -Sex: -[%+ cgi.param('sex') %] +Gender: +[%+ cgi.param('gender') %] City: [%+ cgi.param('city') %] @@ -50,7 +50,7 @@ IM: - [% END %] -Mozillians.org Account: +Mozillians.org Account URL: [% IF cgi.param('mozillian') %] [%+ cgi.param('mozillian') %] [% ELSE %] @@ -58,17 +58,13 @@ Mozillians.org Account: [% END %] References: -[% IF cgi.param('references') %] -[%+ cgi.param('references') %] -[% ELSE %] -- +[% IF cgi.param('cc') %] +[%+ cgi.param('cc').join(", ") %] [% END %] -Currently Involved with Mozilla: +What are you currently doing at Mozilla? [% IF cgi.param('involved') %] [%+ cgi.param('involved') %] -[% ELSE %] -- [% END %] When First Contributed: diff --git a/extensions/REMO/template/en/default/bug/create/create-mozreps.html.tmpl b/extensions/REMO/template/en/default/bug/create/create-mozreps.html.tmpl index be461c795..420c6a8cd 100644 --- a/extensions/REMO/template/en/default/bug/create/create-mozreps.html.tmpl +++ b/extensions/REMO/template/en/default/bug/create/create-mozreps.html.tmpl @@ -20,228 +20,216 @@ [% PROCESS global/variables.none.tmpl %] [% PROCESS global/header.html.tmpl - title = "Mozilla Reps - Application Form" - style_urls = [ "extensions/REMO/web/styles/moz_reps.css" ] + title = "Mozilla Reps - Application Form" + style_urls = [ "extensions/REMO/web/styles/moz_reps.css" ] + yui = [ "autocomplete" ] + jquery = [] + javascript_urls = [ "extensions/REMO/web/js/moz_reps.js", "js/field.js", "js/util.js"] %] -[% USE Bugzilla %] -[% mandatory = '*' %] - - -

Mozilla Reps - Application Form

If you have questions while completing this form, please contact the - Reps Council for - assistance. + Reps Council for assistance.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
First Name:[% mandatory FILTER none %]
Last Name:[% mandatory FILTER none %]
Are you under 18 years old?: -
-
- Mozilla Reps program is not currently accepting people under 18 years old. - Sorry for the inconvenience. In the meantime please check with your local Mozilla - group for other contribution opportunities -
Sex:[% mandatory FILTER none %] - -
City:[% mandatory FILTER none %]
Country:[% mandatory FILTER none %]
Local Community you participate in:
IM (specify service):
Mozillians.org Account:[% mandatory FILTER none %]
- References: -
- -
- How are you involved with Mozilla? -
- -
- When did you first start contributing to Mozilla? -
Languages Spoken:[% mandatory FILTER none %]
How did you learn about Mozilla Reps?[% mandatory FILTER none %]
What motivates you most about joining Mozilla Reps?[% mandatory FILTER none %]
Comments:
- I have read the - Mozilla Privacy Policy:[% mandatory FILTER none %] -
  - -
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [% BLOCK motivation_placeholder -%] + Tell us your goals and what you would be able to do as a Rep that you can't do right now + [%- END %] + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+ +
+ [% INCLUDE global/userselect.html.tmpl + id => "cc" + name => "cc" + value => cc + size => 60 + classes => ["bz_userfield"] + multiple => 5 + %] +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
  + +
[% PROCESS global/footer.html.tmpl %] diff --git a/extensions/REMO/template/en/default/bug/create/created-mozreps.html.tmpl b/extensions/REMO/template/en/default/bug/create/created-mozreps.html.tmpl index a8a3ca112..0ded8744f 100644 --- a/extensions/REMO/template/en/default/bug/create/created-mozreps.html.tmpl +++ b/extensions/REMO/template/en/default/bug/create/created-mozreps.html.tmpl @@ -27,12 +27,25 @@

Thank you!

-Thank you for submitting your Mozilla Reps Application Form. A Mozilla Rep -mentor will contact you shortly at your bugzilla email address. + Thanks for submitting your application to the Reps Program. +

+ +

+ What happens next: +

+ + + +

+ This might take some time, so we apologize for any delays and thank you for your patience.

-Reference: #[% id FILTER html %] + Reference: #[% id FILTER html %]

[% PROCESS global/footer.html.tmpl %] diff --git a/extensions/REMO/web/js/moz_reps.js b/extensions/REMO/web/js/moz_reps.js new file mode 100644 index 000000000..88c60df51 --- /dev/null +++ b/extensions/REMO/web/js/moz_reps.js @@ -0,0 +1,87 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This Source Code Form is "Incompatible With Secondary Licenses", as + * defined by the Mozilla Public License, v. 2.0. */ + +$(document).ready(function() { + 'use strict'; + + var first_time = $("#first_time"); + first_time.prop("checked", true); + first_time.change(function(evt) { + if (!this.checked) { + $("#prior_bug").show(); + $("#prior_bug label").addClass("required"); + } + else { + $("#prior_bug").hide(); + $("#prior_bug label").removeClass("required"); + } + }).change(); + + $("#underage").change(function(evt) { + if (this.checked) { + $('#underage_warning').show(); + $('#submit').prop("disabled", true); + } + else { + $('#underage_warning').hide(); + $('#submit').prop("disabled", false); + } + }).change(); + + $("#privacy").change(function(evt) { + if (this.checked) { + $('#submit').prop("disabled", false); + } + else { + $('#submit').prop("disabled", true); + } + }).change(); + + $('#tmRequestForm').submit(function (event) { + var mozillian_re = /^https?:\/\/(www\.)?mozillians.org\/([^\/]+\/)?u\/[^\/]+$/i; + var errors = []; + var missing = false; + + $('label.required').each(function (index) { + var id = $(this).attr("for"); + var input = $("#" + id); + + if (id == 'mozillian') { + if (!input.val().match(mozillian_re)) { + input.addClass("missing"); + errors.push("The Mozillian Account URL is invalid"); + event.preventDefault(); + } + else { + input.removeClass("missing"); + } + } + else { + if (input.val() == "") { + input.addClass("missing"); + missing = true; + event.preventDefault(); + } + else { + input.removeClass("missing"); + } + } + }); + + if (missing) { + errors.push("There are missing required fields"); + } + + if (errors.length) { + alert(errors.join("\n")); + } + + $('#short_desc').val( + "Application Form: " + $('#first_name').val() + ' ' + $('#last_name').val() + ); + }); +}); diff --git a/extensions/REMO/web/styles/moz_reps.css b/extensions/REMO/web/styles/moz_reps.css index 216bdd234..884dc5896 100644 --- a/extensions/REMO/web/styles/moz_reps.css +++ b/extensions/REMO/web/styles/moz_reps.css @@ -32,6 +32,11 @@ font-size: 80%; } +label.required:before { + content: "* "; + color: red; +} + #reps-form .missing { box-shadow: #FF0000 0 0 1.5px 1px; } -- cgit v1.2.3-24-g4f1b