From: Andy Allan Date: Wed, 12 Jul 2017 09:16:11 +0000 (+0100) Subject: Merge branch 'master' into moderation X-Git-Tag: live~3010^2~116 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/dbd88d893f3c3fce9cafd666b94396988646d81f Merge branch 'master' into moderation --- dbd88d893f3c3fce9cafd666b94396988646d81f diff --cc Gemfile.lock index a00712521,9b79e9ca1..f25e2e7f0 --- a/Gemfile.lock +++ b/Gemfile.lock @@@ -2,52 -2,56 +2,57 @@@ GE remote: https://rubygems.org/ specs: SystemTimer (1.2.3) + aasm (4.1.0) - actionmailer (4.2.7) - actionpack (= 4.2.7) - actionview (= 4.2.7) - activejob (= 4.2.7) + actioncable (5.0.4) + actionpack (= 5.0.4) + nio4r (>= 1.2, < 3.0) + websocket-driver (~> 0.6.1) + actionmailer (5.0.4) + actionpack (= 5.0.4) + actionview (= 5.0.4) + activejob (= 5.0.4) mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.7) - actionview (= 4.2.7) - activesupport (= 4.2.7) - rack (~> 1.6) - rack-test (~> 0.6.2) - rails-dom-testing (~> 1.0, >= 1.0.5) + rails-dom-testing (~> 2.0) + actionpack (5.0.4) + actionview (= 5.0.4) + activesupport (= 5.0.4) + rack (~> 2.0) + rack-test (~> 0.6.3) + rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionpack-page_caching (1.0.2) - actionpack (>= 4.0.0, < 5) - actionview (4.2.7) - activesupport (= 4.2.7) + actionpack-page_caching (1.1.0) + actionpack (>= 4.0.0, < 6) + actionview (5.0.4) + activesupport (= 5.0.4) builder (~> 3.1) erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - activejob (4.2.7) - activesupport (= 4.2.7) - globalid (>= 0.3.0) - activemodel (4.2.7) - activesupport (= 4.2.7) - builder (~> 3.1) - activerecord (4.2.7) - activemodel (= 4.2.7) - activesupport (= 4.2.7) - arel (~> 6.0) - activesupport (4.2.7) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.0.4) + activesupport (= 5.0.4) + globalid (>= 0.3.6) + activemodel (5.0.4) + activesupport (= 5.0.4) + activerecord (5.0.4) + activemodel (= 5.0.4) + activesupport (= 5.0.4) + arel (~> 7.0) + activesupport (5.0.4) + concurrent-ruby (~> 1.0, >= 1.0.2) i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - addressable (2.4.0) - arel (6.0.3) + addressable (2.5.1) + public_suffix (~> 2.0, >= 2.0.2) + arel (7.1.4) ast (2.3.0) - autoprefixer-rails (6.3.7) + autoprefixer-rails (7.1.1.2) execjs bigdecimal (1.1.0) - builder (3.2.2) - capybara (2.7.1) + builder (3.2.3) + canonical-rails (0.2.0) + rails (>= 4.1, < 5.2) + capybara (2.14.3) addressable mime-types (>= 1.16) nokogiri (>= 1.3.3) diff --cc app/models/notifier.rb index 1b1da7b5e,8f9e3e295..54eb9b418 --- a/app/models/notifier.rb +++ b/app/models/notifier.rb @@@ -172,19 -189,29 +189,40 @@@ class Notifier < ActionMailer::Bas end end + def new_issue_notification(issue_id, recipient) + with_recipient_locale recipient do + @url = url_for(:host => SERVER_URL, + :controller => "issues", + :action => "show", + :id => issue_id) + subject = I18n.t("notifier.new_issue_notification.subject") + mail :to => recipient.email, :subject => subject + end + end + private + def set_shared_template_vars + @root_url = root_url(:host => SERVER_URL) + end + + def attach_project_logo + attachments.inline["logo.png"] = File.read(Rails.root.join("app", "assets", "images", "osm_logo_30.png")) + end + + def attach_user_avatar(user) + attachments.inline["avatar.png"] = File.read(user_avatar_file_path(user)) + end + + def user_avatar_file_path(user) + image = user && user.image + if image && image.file? + return image.path(:small) + else + return Rails.root.join("app", "assets", "images", "users", "images", "small.png") + end + end + def with_recipient_locale(recipient) I18n.with_locale Locale.available.preferred(recipient.preferred_languages) do yield diff --cc app/models/user.rb index 6fbf8eecb,3ce48e7cd..63c9527c7 --- a/app/models/user.rb +++ b/app/models/user.rb @@@ -26,14 -28,8 +28,14 @@@ class User < ActiveRecord::Bas has_many :roles, :class_name => "UserRole" + has_many :issues, :class_name => "Issue", :foreign_key => :reported_user_id + has_one :issue, :class_name => "Issue", :foreign_key => :updated_by + has_many :issue_comments + + has_many :reports + - scope :visible, -> { where(:status => %w(pending active confirmed)) } - scope :active, -> { where(:status => %w(active confirmed)) } + scope :visible, -> { where(:status => %w[pending active confirmed]) } + scope :active, -> { where(:status => %w[active confirmed]) } scope :identifiable, -> { where(:data_public => true) } has_attached_file :image, diff --cc config/locales/en-GB.yml index ea13cf0f8,430af7d45..c5b2630cf --- a/config/locales/en-GB.yml +++ b/config/locales/en-GB.yml @@@ -1466,11 -1359,8 +1476,13 @@@ en-GB partial_changeset_with_comment: with comment '%{changeset_comment}' partial_changeset_without_comment: without comment details: More details about the changeset can be found at %{url}. + unsubscribe: To unsubscribe from updates to this changeset, visit %{url} and + click "Unsubscribe". + new_issue_notification: + subject: "[OpenStreetMap] New Issue" + greeting: "Hi," + new_issue: "A new issue has been created" + url: You can view the issue here message: inbox: title: Inbox diff --cc config/locales/en.yml index dc59506e8,a05083a1e..558e960b4 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@@ -1235,8 -1116,8 +1233,8 @@@ en paragraph_1_html: | OpenStreetMap has few formal rules but we expect all participants to collaborate with, and communicate with, the community. If you are considering -- any activities other than editing by hand, please read and follow the guidelines on -- Imports and ++ any activities other than editing by hand, please read and follow the guidelines on ++ Imports and Automated Edits. questions: title: Any questions? @@@ -1262,7 -1143,7 +1260,7 @@@ title: Join the community explanation_html: | If you have noticed a problem with our map data, for example a road is missing or your address, the best way to -- proceed is to join the OpenStreetMap community and add or repair the data yourself. ++ proceed is to join the OpenStreetMap community and add or repair the data yourself. add_a_note: instructions_html: | Just click or the same icon on the map display. @@@ -1272,8 -1153,8 +1270,8 @@@ title: Other concerns explanation_html: | If you have concerns about how our data is being used or about the contents please consult our -- copyright page for more legal information, or contact the appropriate -- OSMF working group. ++ copyright page for more legal information, or contact the appropriate ++ OSMF working group. help_page: title: Getting Help introduction: | @@@ -1341,11 -1222,13 +1339,13 @@@ License page for details. legal_title: Legal legal_html: | -- This site and many other related services are formally operated by the -- OpenStreetMap Foundation (OSMF) - on behalf of the community. -
- Please contact the OSMF - on behalf of the community. Use of all OSMF operated services is subject ++ This site and many other related services are formally operated by the ++ OpenStreetMap Foundation (OSMF) ++ on behalf of the community. Use of all OSMF operated services is subject + to our + Acceptable Use Policies and our Privacy Policy -
- Please contact the OSMF ++
++ Please contact the OSMF if you have licensing, copyright or other legal questions and issues. partners_title: Partners notifier: @@@ -1434,11 -1319,7 +1436,12 @@@ partial_changeset_with_comment: "with comment '%{changeset_comment}'" partial_changeset_without_comment: "without comment" details: "More details about the changeset can be found at %{url}." + unsubscribe: 'To unsubscribe from updates to this changeset, visit %{url} and click "Unsubscribe".' + new_issue_notification: + subject: "[OpenStreetMap] New Issue" + greeting: "Hi," + new_issue: "A new issue has been created" + url: You can view the issue here message: inbox: title: "Inbox" diff --cc db/structure.sql index 53be24a5a,08aafa8d7..be0603e6e --- a/db/structure.sql +++ b/db/structure.sql @@@ -1979,41 -1866,20 +2017,55 @@@ CREATE UNIQUE INDEX index_changesets_su CREATE UNIQUE INDEX index_client_applications_on_key ON client_applications USING btree (key); + -- + -- Name: index_client_applications_on_user_id; Type: INDEX; Schema: public; Owner: - + -- + + CREATE INDEX index_client_applications_on_user_id ON client_applications USING btree (user_id); + + + -- + -- Name: index_diary_entry_subscriptions_on_diary_entry_id; Type: INDEX; Schema: public; Owner: - + -- + + CREATE INDEX index_diary_entry_subscriptions_on_diary_entry_id ON diary_entry_subscriptions USING btree (diary_entry_id); + + +-- +-- Name: index_issue_comments_on_commenter_user_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_issue_comments_on_commenter_user_id ON issue_comments USING btree (commenter_user_id); + + +-- +-- Name: index_issue_comments_on_issue_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_issue_comments_on_issue_id ON issue_comments USING btree (issue_id); + + +-- +-- Name: index_issues_on_reportable_id_and_reportable_type; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_issues_on_reportable_id_and_reportable_type ON issues USING btree (reportable_id, reportable_type); + + +-- +-- Name: index_issues_on_reported_user_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_issues_on_reported_user_id ON issues USING btree (reported_user_id); + + +-- +-- Name: index_issues_on_updated_by; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_issues_on_updated_by ON issues USING btree (updated_by); + + -- -- Name: index_note_comments_on_body; Type: INDEX; Schema: public; Owner: - -- @@@ -2042,20 -1908,13 +2094,27 @@@ CREATE UNIQUE INDEX index_oauth_nonces_ CREATE UNIQUE INDEX index_oauth_tokens_on_token ON oauth_tokens USING btree (token); + -- + -- Name: index_oauth_tokens_on_user_id; Type: INDEX; Schema: public; Owner: - + -- + + CREATE INDEX index_oauth_tokens_on_user_id ON oauth_tokens USING btree (user_id); + + +-- +-- Name: index_reports_on_issue_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_reports_on_issue_id ON reports USING btree (issue_id); + + +-- +-- Name: index_reports_on_reporter_user_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_reports_on_reporter_user_id ON reports USING btree (reporter_user_id); + + -- -- Name: index_user_blocks_on_user_id; Type: INDEX; Schema: public; Owner: - -- @@@ -2706,194 -2533,101 +2781,102 @@@ ALTER TABLE ONLY way SET search_path TO "$user", public; - INSERT INTO schema_migrations (version) VALUES ('1'); - - INSERT INTO schema_migrations (version) VALUES ('10'); - - INSERT INTO schema_migrations (version) VALUES ('11'); - - INSERT INTO schema_migrations (version) VALUES ('12'); - - INSERT INTO schema_migrations (version) VALUES ('13'); - - INSERT INTO schema_migrations (version) VALUES ('14'); - - INSERT INTO schema_migrations (version) VALUES ('15'); - - INSERT INTO schema_migrations (version) VALUES ('16'); - - INSERT INTO schema_migrations (version) VALUES ('17'); - - INSERT INTO schema_migrations (version) VALUES ('18'); - - INSERT INTO schema_migrations (version) VALUES ('19'); - - INSERT INTO schema_migrations (version) VALUES ('2'); - - INSERT INTO schema_migrations (version) VALUES ('20'); - - INSERT INTO schema_migrations (version) VALUES ('20100513171259'); - - INSERT INTO schema_migrations (version) VALUES ('20100516124737'); - - INSERT INTO schema_migrations (version) VALUES ('20100910084426'); - - INSERT INTO schema_migrations (version) VALUES ('20101114011429'); - - INSERT INTO schema_migrations (version) VALUES ('20110322001319'); - - INSERT INTO schema_migrations (version) VALUES ('20110508145337'); - - INSERT INTO schema_migrations (version) VALUES ('20110521142405'); - - INSERT INTO schema_migrations (version) VALUES ('20110925112722'); - - INSERT INTO schema_migrations (version) VALUES ('20111116184519'); - - INSERT INTO schema_migrations (version) VALUES ('20111212183945'); - - INSERT INTO schema_migrations (version) VALUES ('20120123184321'); - - INSERT INTO schema_migrations (version) VALUES ('20120208122334'); - - INSERT INTO schema_migrations (version) VALUES ('20120208194454'); - - INSERT INTO schema_migrations (version) VALUES ('20120214210114'); - - INSERT INTO schema_migrations (version) VALUES ('20120219161649'); - - INSERT INTO schema_migrations (version) VALUES ('20120318201948'); - - INSERT INTO schema_migrations (version) VALUES ('20120328090602'); - - INSERT INTO schema_migrations (version) VALUES ('20120404205604'); - - INSERT INTO schema_migrations (version) VALUES ('20120808231205'); - - INSERT INTO schema_migrations (version) VALUES ('20121005195010'); - - INSERT INTO schema_migrations (version) VALUES ('20121012044047'); - - INSERT INTO schema_migrations (version) VALUES ('20121119165817'); - - INSERT INTO schema_migrations (version) VALUES ('20121202155309'); - - INSERT INTO schema_migrations (version) VALUES ('20121203124841'); - - INSERT INTO schema_migrations (version) VALUES ('20130328184137'); - - INSERT INTO schema_migrations (version) VALUES ('20131029121300'); - - INSERT INTO schema_migrations (version) VALUES ('20131212124700'); - - INSERT INTO schema_migrations (version) VALUES ('20140115192822'); - - INSERT INTO schema_migrations (version) VALUES ('20140117185510'); - - INSERT INTO schema_migrations (version) VALUES ('20140210003018'); - - INSERT INTO schema_migrations (version) VALUES ('20140507110937'); - - INSERT INTO schema_migrations (version) VALUES ('20140519141742'); - - INSERT INTO schema_migrations (version) VALUES ('20150110152606'); - - INSERT INTO schema_migrations (version) VALUES ('20150111192335'); - - INSERT INTO schema_migrations (version) VALUES ('20150222101847'); - - INSERT INTO schema_migrations (version) VALUES ('20150818224516'); - - INSERT INTO schema_migrations (version) VALUES ('20160822153055'); - - INSERT INTO schema_migrations (version) VALUES ('20160822153115'); - - INSERT INTO schema_migrations (version) VALUES ('20160822153153'); - - INSERT INTO schema_migrations (version) VALUES ('21'); - - INSERT INTO schema_migrations (version) VALUES ('22'); - - INSERT INTO schema_migrations (version) VALUES ('23'); - - INSERT INTO schema_migrations (version) VALUES ('24'); - - INSERT INTO schema_migrations (version) VALUES ('25'); - - INSERT INTO schema_migrations (version) VALUES ('26'); - - INSERT INTO schema_migrations (version) VALUES ('27'); - - INSERT INTO schema_migrations (version) VALUES ('28'); - - INSERT INTO schema_migrations (version) VALUES ('29'); - - INSERT INTO schema_migrations (version) VALUES ('3'); - - INSERT INTO schema_migrations (version) VALUES ('30'); - - INSERT INTO schema_migrations (version) VALUES ('31'); - - INSERT INTO schema_migrations (version) VALUES ('32'); - - INSERT INTO schema_migrations (version) VALUES ('33'); - - INSERT INTO schema_migrations (version) VALUES ('34'); - - INSERT INTO schema_migrations (version) VALUES ('35'); - - INSERT INTO schema_migrations (version) VALUES ('36'); - - INSERT INTO schema_migrations (version) VALUES ('37'); - - INSERT INTO schema_migrations (version) VALUES ('38'); - - INSERT INTO schema_migrations (version) VALUES ('39'); - - INSERT INTO schema_migrations (version) VALUES ('4'); - - INSERT INTO schema_migrations (version) VALUES ('40'); - - INSERT INTO schema_migrations (version) VALUES ('41'); - - INSERT INTO schema_migrations (version) VALUES ('42'); - - INSERT INTO schema_migrations (version) VALUES ('43'); - - INSERT INTO schema_migrations (version) VALUES ('44'); - - INSERT INTO schema_migrations (version) VALUES ('45'); - - INSERT INTO schema_migrations (version) VALUES ('46'); - - INSERT INTO schema_migrations (version) VALUES ('47'); - - INSERT INTO schema_migrations (version) VALUES ('48'); - - INSERT INTO schema_migrations (version) VALUES ('49'); - - INSERT INTO schema_migrations (version) VALUES ('5'); - - INSERT INTO schema_migrations (version) VALUES ('50'); - - INSERT INTO schema_migrations (version) VALUES ('51'); - - INSERT INTO schema_migrations (version) VALUES ('52'); - - INSERT INTO schema_migrations (version) VALUES ('53'); - - INSERT INTO schema_migrations (version) VALUES ('54'); - - INSERT INTO schema_migrations (version) VALUES ('55'); - - INSERT INTO schema_migrations (version) VALUES ('56'); - - INSERT INTO schema_migrations (version) VALUES ('57'); - - INSERT INTO schema_migrations (version) VALUES ('6'); - - INSERT INTO schema_migrations (version) VALUES ('7'); - - INSERT INTO schema_migrations (version) VALUES ('8'); - - INSERT INTO schema_migrations (version) VALUES ('9'); + INSERT INTO "schema_migrations" (version) VALUES + ('1'), + ('10'), + ('11'), + ('12'), + ('13'), + ('14'), + ('15'), + ('16'), + ('17'), + ('18'), + ('19'), + ('2'), + ('20'), + ('20100513171259'), + ('20100516124737'), + ('20100910084426'), + ('20101114011429'), + ('20110322001319'), + ('20110508145337'), + ('20110521142405'), + ('20110925112722'), + ('20111116184519'), + ('20111212183945'), + ('20120123184321'), + ('20120208122334'), + ('20120208194454'), + ('20120214210114'), + ('20120219161649'), + ('20120318201948'), + ('20120328090602'), + ('20120404205604'), + ('20120808231205'), + ('20121005195010'), + ('20121012044047'), + ('20121119165817'), + ('20121202155309'), + ('20121203124841'), + ('20130328184137'), + ('20131212124700'), + ('20140115192822'), + ('20140117185510'), + ('20140210003018'), + ('20140507110937'), + ('20140519141742'), + ('20150110152606'), + ('20150111192335'), + ('20150222101847'), + ('20150818224516'), ++('20160822153055'), ++('20160822153115'), ++('20160822153153'), + ('20161002153425'), + ('20161011010929'), + ('20170222134109'), + ('21'), + ('22'), + ('23'), + ('24'), + ('25'), + ('26'), + ('27'), + ('28'), + ('29'), + ('3'), + ('30'), + ('31'), + ('32'), + ('33'), + ('34'), + ('35'), + ('36'), + ('37'), + ('38'), + ('39'), + ('4'), + ('40'), + ('41'), + ('42'), + ('43'), + ('44'), + ('45'), + ('46'), + ('47'), + ('48'), + ('49'), + ('5'), + ('50'), + ('51'), + ('52'), + ('53'), + ('54'), + ('55'), + ('56'), + ('57'), + ('6'), + ('7'), + ('8'), + ('9'); - -