From 834ddfcdeacb606a1c689d88dced3db0130f3d2e Mon Sep 17 00:00:00 2001 From: Bobby Date: Tue, 20 Aug 2019 13:20:43 -0500 Subject: [PATCH] ope --- app/controllers/api/v2/me.rb | 1 + app/controllers/api/v2/users.rb | 1 + app/controllers/users_controller.rb | 2 +- app/helpers/application_helper.rb | 19 ++++++++++++++ app/views/users/_edit_sharing.html.haml | 15 +++++++++++ .../20190820175100_add_instagram_to_users.rb | 5 ++++ db/structure.sql | 26 ++++++------------- 7 files changed, 50 insertions(+), 19 deletions(-) create mode 100644 db/migrate/20190820175100_add_instagram_to_users.rb diff --git a/app/controllers/api/v2/me.rb b/app/controllers/api/v2/me.rb index aa42804a05..895d1e0286 100644 --- a/app/controllers/api/v2/me.rb +++ b/app/controllers/api/v2/me.rb @@ -13,6 +13,7 @@ def user_info email: current_user.email, secondary_emails: current_user.secondary_emails, twitter: (current_user.twitter if current_user.show_twitter), + instagram: (current_user.instagram if current_user.show_instagram), image: (current_user.avatar_url if current_user.show_bikes), }, } diff --git a/app/controllers/api/v2/users.rb b/app/controllers/api/v2/users.rb index b9129e2742..e2d9f6c15d 100644 --- a/app/controllers/api/v2/users.rb +++ b/app/controllers/api/v2/users.rb @@ -11,6 +11,7 @@ def user_info name: current_user.name, email: current_user.email, twitter: (current_user.twitter if current_user.show_twitter), + instagram: (current_user.instagram if current_user.show_instagram), image: (current_user.avatar_url if current_user.show_bikes), } end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6fe16d9601..9e55470aea 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -188,7 +188,7 @@ def permitted_parameters :additional_emails, :title, :description, :phone, :street, :city, :zipcode, :country_id, :state_id, :avatar, :avatar_cache, :twitter, :show_twitter, :website, :show_website, :show_bikes, :show_phone, :my_bikes_link_target, :my_bikes_link_title, :password, - :password_confirmation, :preferred_language) + :password_confirmation, :preferred_language, :show_instagram) .merge(sign_in_partner.present? ? { partner_data: { sign_up: sign_in_partner } } : {}) end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index cdaeeaac95..be9d7e7e11 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -212,6 +212,25 @@ def show_twitter_and_website(user) end end + def instagramable(user) + if user.show_instagram and user.instagram + link_to "instagram", "https://instagram.com/#{user.instagram}" + end + end + + def show_instagram_and_website(user) + if instagramable(user) or websiteable(user) + html = "" + if instagramable(user) + html << twitterable(user) + html << " and #{websiteable(user)}" if websiteable(user) + else + html << websiteable(user) + end + html.html_safe + end + end + def pretty_print_json(data) require "coderay" CodeRay.scan(JSON.pretty_generate(data), :json).div.html_safe diff --git a/app/views/users/_edit_sharing.html.haml b/app/views/users/_edit_sharing.html.haml index 18ec757d8d..4e43665f60 100644 --- a/app/views/users/_edit_sharing.html.haml +++ b/app/views/users/_edit_sharing.html.haml @@ -17,6 +17,21 @@ = f.label :twitter, t(".twitter_handle"), class: 'form-well-label' .form-well-input = f.text_field :twitter, placeholder: t(".twitter_handle"), class: 'form-control' + .related-fields + .form-group.row.sharing-collapser{ data: { target: '#instagram-field' } } + %label.form-well-label + Fix + .form-well-input + %label.radio-inline + = f.radio_button :show_instagram, true + Fix + %label.radio-inline + = f.radio_button :show_instagram, false + Fix + #instagram-field.form-group.row.collapse + = f.label :instagram, t(".instagram_handle"), class: 'form-well-label' + .form-well-input + = f.text_field :instagram, placeholder: t(".instagram_handle"), class: 'form-control' .form-group.row.sharing-collapser{ data: { target: '#personal-field' } } %label.form-well-label diff --git a/db/migrate/20190820175100_add_instagram_to_users.rb b/db/migrate/20190820175100_add_instagram_to_users.rb new file mode 100644 index 0000000000..321d32c8b9 --- /dev/null +++ b/db/migrate/20190820175100_add_instagram_to_users.rb @@ -0,0 +1,5 @@ +class AddInstagramToUsers < ActiveRecord::Migration + def change + add_column :users, :instagram, :string + end +end diff --git a/db/structure.sql b/db/structure.sql index b1176241a7..2135dd03b5 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -2,8 +2,8 @@ -- PostgreSQL database dump -- --- Dumped from database version 10.3 --- Dumped by pg_dump version 10.3 +-- Dumped from database version 11.3 +-- Dumped by pg_dump version 11.3 SET statement_timeout = 0; SET lock_timeout = 0; @@ -12,23 +12,10 @@ SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SELECT pg_catalog.set_config('search_path', '', false); SET check_function_bodies = false; +SET xmloption = content; SET client_min_messages = warning; SET row_security = off; --- --- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: - --- - -CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; - - --- --- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: - --- - -COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; - - -- -- Name: fuzzystrmatch; Type: EXTENSION; Schema: -; Owner: - -- @@ -2253,7 +2240,8 @@ CREATE TABLE public.users ( my_bikes_hash jsonb, preferred_language character varying, last_login_ip character varying, - magic_link_token text + magic_link_token text, + instagram character varying ); @@ -4544,7 +4532,9 @@ INSERT INTO schema_migrations (version) VALUES ('20190806170520'); INSERT INTO schema_migrations (version) VALUES ('20190806214815'); +INSERT INTO schema_migrations (version) VALUES ('20190809200257'); + INSERT INTO schema_migrations (version) VALUES ('20190809214414'); -INSERT INTO schema_migrations (version) VALUES ('20190809200257'); +INSERT INTO schema_migrations (version) VALUES ('20190820175100');