Skip to content

Commit

Permalink
Merge pull request #963 from PlanoramaEvents/PLAN-892-backend-social-…
Browse files Browse the repository at this point in the history
…media-fields

Plan 892 backend social media fields
  • Loading branch information
Gailbear authored Feb 25, 2024
2 parents 33e7148 + 9a18c3d commit aec128d
Show file tree
Hide file tree
Showing 17 changed files with 114 additions and 71 deletions.
2 changes: 2 additions & 0 deletions app/controllers/people_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,8 @@ def allowed_params
bio
website
twitter
fediverse
bsky
othersocialmedia
facebook
linkedin
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/reports/people_reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def social_media
social << "TikTok: https://www.tiktok.com/@#{person.tiktok}" unless person.tiktok.blank?
social << "LinkedIn: https://linkedin.com/in/#{person.linkedin}" unless person.linkedin.blank?
social << "Other Social Media: #{person.othersocialmedia}" unless person.othersocialmedia.blank?
social << "Fediverse: #{person.fediverse}" unless person.fediverse.blank?
social << "BlueSky: https://bsky.app/profile/#{person.bsky}" unless person.bsky.blank?

worksheet.append_row(
[
Expand Down
33 changes: 0 additions & 33 deletions app/controllers/submission/responses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,4 @@ def belongs_to_relationship
def belongs_to_param_id
params[:submission_id]
end

# def allowed_params
# %i[
# id
# text
# submission
# ] << [
# answers: [],
# address: %i[
# id
# street
# street2
# city
# state
# zip
# country
# response
# ],
# socialmedia: %i[
# id
# twitter
# facebook
# linkedin
# twitch
# youtube
# instagram
# website
# other
# tiktok
# response
# ]
# ]
# end
end
10 changes: 7 additions & 3 deletions app/javascript/constants/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ module.exports = {
willing_to_moderate: "Moderation interest",
languages_fluent_in: "Fluent languages",
contact_email: "Contact email",
twitter: "Twitter",
twitter: "X (formerly Twitter)",
facebook: "Facebook",
website: "Website",
instagram: "Instagram",
Expand All @@ -206,6 +206,8 @@ module.exports = {
linkedin: "LinkedIn",
flickr: "Flickr",
reddit: "Reddit",
bsky: "Bluesky",
fediverse: "Fediverse",
othersocialmedia: "Other Social Media",
socialmedia: "Social Media",
can_share: "Permission to share email with participants"
Expand All @@ -222,7 +224,7 @@ module.exports = {
ADD_CONFLICT_IGNORE_ERROR: "Ignore Conflict Failed",

// Social Links Errors
TWITTER_ID_INVALID_MSG: "Twitter ID is not in a valid format",
TWITTER_ID_INVALID_MSG: "X (formerly Twitter) ID is not in a valid format",
FACEBOOK_ID_INVALID_MSG: "Facebook ID is not in a valid format",
WEBSITE_INVALID_MSG: "Website is not in a valid format",
INSTAGRAM_ID_INVALID_MSG: "Instagram ID is not in a valid format",
Expand All @@ -240,7 +242,7 @@ module.exports = {
black_diaspora: "Member of the global Black diaspora",
non_us_centric_perspectives: "Represent something other than a purely US-centric perspective",
demographic_categories: "Other demographic categories",
twitter: "Twitter",
twitter: "X (formerly Twitter)",
facebook: "Facebook",
website: "Website",
instagram: "Instagram",
Expand All @@ -250,6 +252,8 @@ module.exports = {
linkedin: "LinkedIn",
flickr: "Flickr",
reddit: "Reddit",
bsky: "Bluesky",
fediverse: "Fediverse",
othersocialmedia: "Other",
do_not_assign_with: "Anyone that should not be assigned to be on a panel with participant",
is_local: "Local to the event",
Expand Down
31 changes: 23 additions & 8 deletions app/javascript/profile/person_details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,6 @@
<person-edit-modal id="person-social-modal" :person="selected" :data="socialsData" :validate="true">
<template #modal-title>Edit Socials - {{selected.published_name}}</template>
<template #default="{fields}">
<simple-social
label="Twitter"
:rules="{min: 1, max: 15, regex: /^[a-z0-9_]{1,15}$/i}"
prepend="@"
v-model="fields.twitter"
:disabled="disabled"
></simple-social>
<simple-social
:rules="{min: 5, regex: /^[a-z\d.]{5,}$/i }"
label="Facebook"
Expand Down Expand Up @@ -230,6 +223,26 @@
v-model="fields.linkedin"
:disabled="disabled"
></simple-social>
<simple-social
label="Bluesky"
prepend="@"
v-model="fields.bsky"
:disabled="disabled"
></simple-social>
<simple-social
label="Fediverse"
:rules="{ regex: /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-zA-Z0-9\/]+([\-\.]{1}[a-zA-Z0-9\/]+)*\.[a-zA-Z\/]{2,5}(:[0-9]{1,5})?(\/.*)?$/ }"
prepend="url"
v-model="fields.fediverse"
:disabled="disabled"
></simple-social>
<simple-social
label="X (formerly Twitter)"
:rules="{min: 1, max: 15, regex: /^[a-z0-9_]{1,15}$/i}"
prepend="@"
v-model="fields.twitter"
:disabled="disabled"
></simple-social>
<simple-social
label="Other"
v-model="fields.othersocialmedia"
Expand Down Expand Up @@ -313,14 +326,16 @@ export default {
accommodations: null,
},
socialsData: {
twitter: null,
facebook: null,
website: null,
instagram: null,
twitch: null,
youtube: null,
tiktok: null,
linkedin: null,
bsky: null,
fediverse: null,
twitter: null,
othersocialmedia: null
},
}),
Expand Down
3 changes: 2 additions & 1 deletion app/javascript/store/survey/survey.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ export const surveyStore = {
[NEW_RESPONSE] (state, {relationships = {}, text = '', answers = [], socialmedia = {
twitter: null, facebook: null, linkedin: null,
twitch: null, youtube: null, instagram: null,
tiktok: null, other: null, website: null
tiktok: null, other: null, website: null,
bsky: null, fediverse: null
}}) {
let id = uuidv4();
let item = {
Expand Down
8 changes: 6 additions & 2 deletions app/javascript/surveys/edit-survey-question.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
</template>
<template v-if="socialmedia">
<div class="col-12 col-lg-8 col-xl-6" v-if="!isSelected">
<b-form-group label="Twitter" label-cols="3"><b-input-group prepend="@"><b-form-input type="text" disabled></b-form-input></b-input-group></b-form-group>
<b-form-group label="Facebook" label-cols="3"><b-input-group>
<template #prepend>
<b-input-group-text>facebook.com&sol;</b-input-group-text>
Expand Down Expand Up @@ -99,6 +98,9 @@
</template>
<b-form-input type="text" disabled></b-form-input>
</b-input-group></b-form-group>
<b-form-group label="Bluesky" label-cols="3"><b-input-group prepend="@"><b-form-input type="text" disabled></b-form-input></b-input-group></b-form-group>
<b-form-group label="Fediverse" label-cols="3"><b-input-group prepend="url"><b-form-input type="text" disabled></b-form-input></b-input-group></b-form-group>
<b-form-group label="X (formerly Twitter)" label-cols="3"><b-input-group prepend="@"><b-form-input type="text" disabled></b-form-input></b-input-group></b-form-group>
<b-form-group label="Other" label-cols="3"><b-form-input type="text" disabled></b-form-input></b-form-group>
</div>
<div class="col-12">
Expand Down Expand Up @@ -215,12 +217,14 @@ export default {
computed: {
socials() {
return [
{value: "twitter", text: "Twitter"},
{value: "facebook", text: "Facebook"},
{value: "twitch", text: "Twitch"},
{value: "youtube", text: "YouTube"},
{value: "instagram", text: "Instagram"},
{value: "website", text: "Website"},
{value: "bsky", text: "Bluesky"},
{value: "fediverse", text: "Fediverse"},
{value: "twitter", text: "X (formerly Twitter)"},
]
},
displayLinkedField() {
Expand Down
5 changes: 4 additions & 1 deletion app/javascript/surveys/response.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export const responseMixin = {
const socialmedia = {
twitter: null, facebook: null, linkedin: null,
twitch: null, youtube: null, instagram: null,
tiktok: null, other: null, website: null
tiktok: null, other: null, website: null,
bsky: null, fediverse: null
}
// first check for a linked field
// console.debug("now i have both", this.question, this.selectedSubmission)
Expand All @@ -76,6 +77,8 @@ export const responseMixin = {
socialmedia.tiktok = this.currentUser.tiktok
socialmedia.other = this.currentUser.othersocialmedia
socialmedia.website = this.currentUser.website
socialmedia.bsky = this.currentUser.bsky
socialmedia.fediverse = this.currentUser.fediverse
} else if (fieldName=='contact_email') {
text = this.currentUser.contact_email.email
} else { // text answer
Expand Down
35 changes: 26 additions & 9 deletions app/javascript/surveys/survey_question.vue
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,6 @@
<linked-field-icon :linked_field="question.linked_field"></linked-field-icon>
<div :class="['row', 'ml-0', {'w-50': answerable}]">
<div class="col-12 px-0">
<simple-social
label="Twitter"
prepend="@"
:disabled="!answerable"
:id="formId('socials-twitter')"
v-model="localResponse.response.socialmedia.twitter"
@blur="saveResponse(localResponse, selectedSubmission)"
></simple-social>
<simple-social
label="Facebook"
:disabled="!answerable"
Expand Down Expand Up @@ -278,6 +270,30 @@
<b-input-group-text>linkedin.com&sol;in&sol;</b-input-group-text>
</template>
</simple-social>
<simple-social
label="Bluesky"
prepend="@"
:disabled="!answerable"
:id="formId('socials-bsky')"
v-model="localResponse.response.socialmedia.bsky"
@blur="saveResponse(localResponse, selectedSubmission)"
></simple-social>
<simple-social
label="Fediverse"
prepend="url"
:disabled="!answerable"
:id="formId('socials-fediverse')"
v-model="localResponse.response.socialmedia.fediverse"
@blur="saveResponse(localResponse, selectedSubmission)"
></simple-social>
<simple-social
label="X (formerly Twitter)"
prepend="@"
:disabled="!answerable"
:id="formId('socials-twitter')"
v-model="localResponse.response.socialmedia.twitter"
@blur="saveResponse(localResponse, selectedSubmission)"
></simple-social>
<simple-social
label="Other"
:disabled="!answerable"
Expand Down Expand Up @@ -398,7 +414,8 @@ export default {
}, socialmedia: {
twitter: null, facebook: null, linkedin: null,
twitch: null, youtube: null, instagram: null,
tiktok: null, other: null, website: null
tiktok: null, other: null, website: null,
bsky: null, fediverse: null
}}
}
}
Expand Down
4 changes: 4 additions & 0 deletions app/models/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# availability_notes :string
# bio :text
# black_diaspora :string(10000)
# bsky :string
# can_photo :enum default("no")
# can_photo_exceptions :string(10000)
# can_record :enum default("no")
Expand All @@ -31,6 +32,7 @@
# excluded_demographic_categories :string
# facebook :string
# failed_attempts :integer default(0), not null
# fediverse :string
# flickr :string
# gender :string(400)
# global_diaspora :string
Expand Down Expand Up @@ -250,6 +252,8 @@ def scheduled
:pseudonym,
:website,
:twitter,
:fediverse,
:bsky,
:othersocialmedia,
:facebook,
:linkedin,
Expand Down
5 changes: 4 additions & 1 deletion app/models/survey/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def update_linked
submission.person.tiktok = val['tiktok']
submission.person.othersocialmedia = val['other']
submission.person.website = val['website']
submission.person.fediverse = val['fediverse']
submission.person.bsky = val['bsky']
else
if check_update_linked
existing = submission.person.send("#{details[1]}")
Expand Down Expand Up @@ -195,7 +197,8 @@ def self.empty_json
text: "",
answers: [],
socialmedia: {
twitter: nil, facebook: nil, linkedin: nil, twitch: nil, youtube: nil, instagram: nil, tiktok: nil, other: nil, website: nil
twitter: nil, facebook: nil, linkedin: nil, twitch: nil, youtube: nil, instagram: nil, tiktok: nil, other: nil, website: nil,
bsky: nil, fediverse: nil
}
}
end
Expand Down
2 changes: 2 additions & 0 deletions app/serializers/conclar/participant_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class Conclar::ParticipantSerializer < ActiveModel::Serializer
res['tiktok'] = "https://www.tiktok.com/@#{object.tiktok}" unless object.tiktok.blank?
res['linkedin'] = "https://linkedin.com/in/#{object.linkedin}" unless object.linkedin.blank?
res['othersocialmedia'] = object.othersocialmedia unless object.othersocialmedia.blank?
res['fediverse'] = object.fediverse unless object.fediverse.blank?
res['bsky'] = "https://bsky.app/profile/#{object.bsky}" unless object.bsky.blank?

res
end
Expand Down
3 changes: 3 additions & 0 deletions app/serializers/person_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# availability_notes :string
# bio :text
# black_diaspora :string(10000)
# bsky :string
# can_photo :enum default("no")
# can_photo_exceptions :string(10000)
# can_record :enum default("no")
Expand All @@ -31,6 +32,7 @@
# excluded_demographic_categories :string
# facebook :string
# failed_attempts :integer default(0), not null
# fediverse :string
# flickr :string
# gender :string(400)
# global_diaspora :string
Expand Down Expand Up @@ -115,6 +117,7 @@ class PersonSerializer #< ActiveModel::Serializer
:can_share,
:registered, :registration_type, :registration_number,
:bio, :website, :twitter, :othersocialmedia,
:fediverse, :bsky,
:facebook, :linkedin, :twitch, :youtube,
:instagram, :flickr, :reddit, :tiktok,
:can_stream,
Expand Down
27 changes: 16 additions & 11 deletions app/services/access_control_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,22 @@ def self.attribute_meta_data
registration_number: { sensitive: true, linkable: false, type: :string},
attendance_type: { sensitive: false, linkable: true, type: :attendance_type, values: ['in person', 'virtual', 'hybrid']},
bio: { sensitive: false, linkable: true, type: :text},
website: { sensitive: false, linkable: true, type: :string},
twitter: { sensitive: false, linkable: true, type: :string},
othersocialmedia: { sensitive: false, linkable: true, type: :string},
facebook: { sensitive: false, linkable: true, type: :string},
linkedin: { sensitive: false, linkable: true, type: :string},
twitch: { sensitive: false, linkable: true, type: :string},
youtube: { sensitive: false, linkable: true, type: :string},
instagram: { sensitive: false, linkable: true, type: :string},
flickr: { sensitive: false, linkable: true, type: :string},
reddit: { sensitive: false, linkable: true, type: :string},
tiktok: { sensitive: false, linkable: true, type: :string},
# NOTE: we really do not want individual social media fields to be linked,
# this was done as the google form migration. Surveys in Plano should use
# the social media question type
# website: { sensitive: false, linkable: true, type: :string},
# twitter: { sensitive: false, linkable: true, type: :string},
# fediverse: { sensitive: false, linkable: true, type: :string},
# bsky: { sensitive: false, linkable: true, type: :string},
# othersocialmedia: { sensitive: false, linkable: true, type: :string},
# facebook: { sensitive: false, linkable: true, type: :string},
# linkedin: { sensitive: false, linkable: true, type: :string},
# twitch: { sensitive: false, linkable: true, type: :string},
# youtube: { sensitive: false, linkable: true, type: :string},
# instagram: { sensitive: false, linkable: true, type: :string},
# flickr: { sensitive: false, linkable: true, type: :string},
# reddit: { sensitive: false, linkable: true, type: :string},
# tiktok: { sensitive: false, linkable: true, type: :string},
can_stream: { sensitive: false, linkable: true, type: :yesnomaybe, values: ['yes', 'no', 'maybe']},
can_record: { sensitive: false, linkable: true, type: :yesnomaybe, values: ['yes', 'no', 'maybe']},
can_photo: { sensitive: false, linkable: true, type: :yesnomaybe, values: ['yes', 'no', 'maybe']},
Expand Down
6 changes: 6 additions & 0 deletions db/migrate/20240223134703_add_social_media_fields.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddSocialMediaFields < ActiveRecord::Migration[6.1]
def change
add_column :people, :fediverse, :string, default: nil
add_column :people, :bsky, :string, default: nil
end
end
Loading

0 comments on commit aec128d

Please sign in to comment.