Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add instagram handle to users #1202

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions app/controllers/api/v2/me.rb
Expand Up @@ -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),
},
}
Expand Down
1 change: 1 addition & 0 deletions app/controllers/api/v2/users.rb
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Expand Up @@ -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

Expand Down
19 changes: 19 additions & 0 deletions app/helpers/application_helper.rb
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions app/views/users/_edit_sharing.html.haml
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions 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
26 changes: 8 additions & 18 deletions db/structure.sql
Expand Up @@ -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;
Expand All @@ -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: -
--
Expand Down Expand Up @@ -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
);


Expand Down Expand Up @@ -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');