Remove unused gmail integration

This commit is contained in:
Eric Schultz 2021-02-04 12:06:10 -06:00 committed by Eric Schultz
parent fae212b842
commit 4c1d7ddd4e
21 changed files with 13 additions and 396 deletions

View file

@ -15,11 +15,6 @@ Full license explanation at https://github.com/houdiniproject/houdini/blob/maste
margin: 0px;
}
.supporterEmailRecipients {
float: right;
width: 90%;
}
.panelsLayout .mainPanel .table--plaid tr[is-checked] {
$checked-color: rgba($sage, 0.8);

View file

@ -1,19 +0,0 @@
/* License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE */
@import 'mixins';
.emailModal-tr > td input {
margin-bottom: 0;
}
.emailModal-tr > td:first-of-type {
width: 10%;
padding-right: 10px;
}
.emailModal-tr > td:last-of-type {
width: 90%;
}
.emailModal-tr > td {
padding-bottom: 15px;
}
.emailModal input[readonly] {
border: none;
}

View file

@ -2,7 +2,6 @@
Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE */
@import 'mixins';
@import 'timeline';
@import 'email_modal';
.sidePanel-rightSide {
width: 65%;

View file

@ -1,34 +0,0 @@
# frozen_string_literal: true
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
module Nonprofits
class SupporterEmailsController < ApplicationController
include Controllers::Nonprofit::Current
include Controllers::Nonprofit::Authorization
before_action :authenticate_nonprofit_user!
def create
if params[:selecting_all]
ids = QuerySupporters.full_filter_expr(params[:nonprofit_id], params[:query])
.select('supporters.id')
.execute(format: 'csv')[1..-1].flatten
elsif params[:supporter_ids]
ids = params[:supporter_ids]
end
if ids.nil? || ids.empty?
render json: { errors: 'Supporters not found' }, status: :unprocessable_entity
return
end
render json: { count: ids.count }, status: :ok
end
def gmail
gmail = SupporterEmail.create params[:gmail]
InsertActivities.for_supporter_emails([gmail.id])
render json: gmail
end
end
end

View file

@ -10,12 +10,7 @@ const root = state =>
h('a.table-meta-button.white', {
href: `/nonprofits/${app.nonprofit_id}/campaigns/${ENV.campaignID}/admin/donations.csv`,
target: '_blank',
}, [ h('i.fa.fa-file-text'), ' Export ' ]),
/*
h('a.table-meta-button.green', {
onclick: $.showEmailModal
}, [ h('i.fa.fa-envelope'), ' Email ' ])
*/
}, [ h('i.fa.fa-file-text'), ' Export ' ])
])
module.exports = {

View file

@ -11,7 +11,6 @@ const supporterTable = require('./supporter-table.es6')
var $ = {
showMore: supporterTable.$streams.showMore,
searches: meta.$streams.searches,
showEmailModal: flyd.stream(),
}
const root = state =>

View file

@ -98,20 +98,6 @@ exports.SupporterNote = (data, state) => {
}
}
exports.SupporterEmail = (data, state) => {
var jd = data.json_data
var canView = false
var body = [h('span', `Subject: ${jd.subject}`), h('br')]
var thread = h('a', {props: {href: '#'}, on: {click: [state.threadId$, jd.gmail_thread_id]}}, 'View thread')
return {
title: `Email thread started by ${jd.from}`
, icon: 'fa-envelope'
, body: body
// , body: canView ? R.concat(body, thread) : R.concat(body, signIn)
}
}
exports.OffsitePayment = (data, state) => {
const desig = data.json_data.designation ? `Designation: ${data.json_data.designation}. ` : ''
return {

View file

@ -1,15 +0,0 @@
# frozen_string_literal: true
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
class EmailDraft < ApplicationRecord
# :nonprofit, :nonprofit_id,
# :name,
# :deleted,
# :value,
# :created_at
belongs_to :nonprofit
scope :not_deleted, -> { where(deleted: [nil, false]) }
end

View file

@ -40,7 +40,6 @@ class Supporter < ApplicationRecord
has_many :direct_debit_details
has_many :donations
has_many :supporter_notes, dependent: :destroy
has_many :supporter_emails
has_many :activities, dependent: :destroy
has_many :tickets
has_many :recurring_donations

View file

@ -1,18 +0,0 @@
# frozen_string_literal: true
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
class SupporterEmail < ApplicationRecord
# :to,
# :from,
# :subject,
# :body,
# :recipient_count,
# :supporter_id, :supporter,
# :nonprofit_id,
# :gmail_thread_id
belongs_to :supporter
validates_presence_of :nonprofit_id
has_many :activities, as: :attachment, dependent: :destroy
end

View file

@ -1,38 +0,0 @@
<%- # License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE -%>
<!-- partial start: nonprofits/supporters/_create_or_update_email_draft_modal -->
<div class='modal wide' id='createOrUpdateEmailDraftModal'>
<!--= scope 'emails.drafts' -->
<header class='modal-header'>
<h4 class='modal-header-title'><!--= put this.current.header_text --></h4>
<%= render 'common/modal_close' %>
</header>
<div class='modal-body'>
<form>
<fieldset class='group'>
<label class='u-marginBottom--5'>Subject</label>
<input class='input--300' type='text' name='subject'>
<!--= set_value this.current.name -->
</fieldset>
<div class='editable' required></div>
<div class='u-centered u-marginTop--15'>
<button class='button'>
<!--= set_attr_if this.loading 'disabled' '' -->
<!--= on 'click' (this.save) -->
<span><!--= hide_if this.loading --> Save Draft </span>
<span><!--= show_if this.loading -->Saving...</span>
</button>
</div>
</form>
</div>
<footer class='modal-footer'>
<a open-modal='manageEmailDraftsModal'>
View All Drafts
</a>
</footer>
</div>
<!-- partial end: nonprofits/supporters/_create_or_update_email_draft_modal -->

View file

@ -1,78 +0,0 @@
<%- # License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE -%>
<!-- start partial nonprofits/supporters/_email_modal -->
<div class='modal wide emailModal' id='emailModal'>
<!--= scope 'emails.new.data' -->
<header class='modal-header'>
<h4 class='modal-header-title'>Send Email to
<!--= put this.action_recipient -->
</h4>
<%= render 'common/modal_close' %>
</header>
<div class='modal-body'>
<form>
<section class='group u-marginBottom--10'>
<label class='col-1 u-marginTop--5'>To </label>
<div class='col-right-11 u-paddingLeft--10'>
<span class='bulkActionSubject u-marginRight--5'>
<!--= repeat emails.new.data.selected_with_limit -->
<!--= if (this.email) (put this.email) -->
</span>
<span class='bulkActionSubject--remaining'>
<!--= show_if this.remaining_count -->
And <!--= put this.remaining_count --> more...
</span>
</div>
</section>
<section class='group u-marginBottom--10'>
<label class='col-1 u-marginTop--5'>From </label>
<div class='col-right-11 u-paddingLeft--10'>
<input type='text' name='from' value="<%= @nonprofit.email || current_user.email%>" required>
</div>
</section>
<section class='group'>
<div title='Subject'>
<!--= add_class_if (length emails.drafts.data) 'col-8' -->
<input type='text' class='u-marginBottom--0' name='subject' required placeholder='Subject'>
</div>
<div class='col-right-4 u-paddingLeft--10' title='Draft'>
<!--= show_if (length emails.drafts.data) -->
<%= render 'components/drop_down',
label: 'Use an existing draft',
scope: 'emails.drafts',
click_event: 'emails.drafts.select_drop_down this.id',
extra_option: "Clear selection",
extra_option_click_event: 'emails.drafts.clear_drop_down' %>
</div>
</section>
<p class='u-marginTop--10'><%= render 'components/messages/html_email_disclaimer' %></p>
<div class='editable editable--email u-marginTop--15' required></div>
<div class='u-centered u-marginTop--15'>
<button class='button blue u-marginRight--10'>
<!--= scope 'emails.drafts' -->
<!--= set_attr_if this.loading 'disabled' '' -->
<!--= on 'click' (this.save) -->
<span><!--= hide_if this.loading --> Save Draft </span>
<span><!--= show_if this.loading -->Saving...</span>
</button>
<button class='button'>
<!--= on 'click' emails.preview -->
Preview Before Sending
</button>
</div>
</form>
</div>
</div>
<!-- end partial nonprofits/supporters/_email_modal -->

View file

@ -1,17 +0,0 @@
<%- # License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE -%>
<div class='modal' id='emailReadOnlyModal'>
<header class='modal-header'>
<h4 class='modal-header-title'>
Subject: <!--= put timeline.displaying_email.subject -->
</h4>
<%= render 'common/modal_close' %>
</header>
<div class='modal-body'>
<small class='u-marginBottom--15 u-inlineBlock u-color--grey'><!--= put (readable_date timeline.displaying_email.date) --> </small>
<article class='editable--readOnly editable--email u-padding--10 u-border--light'>
<!--= put timeline.displaying_email.body -->
</article>
</div>
</div>

View file

@ -1,45 +0,0 @@
<%- # License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE -%>
<div class='modal fullScreen' id='manageEmailDraftsModal'>
<!--= scope 'emails.drafts' -->
<%= render 'common/modal_header', title: "Manage Email Drafts" %>
<div class='modal-body'>
<button class='button--small u-marginBottom--20'>
<!--= on 'click' (this.show_new) -->
<i class='fa fa-plus'></i> New Draft</button>
<p class='noResults'>
<!--= hide_if (length this.data) -->
It looks like you don't have any draft. Create one by clicking the button above.</p>
<table class='table--plaid'>
<!--= show_if (length this.data) -->
<thead>
<th>Subject</th>
<th>Message</th>
<th>Date Created</th>
<th></th>
</thead>
<tr>
<!--= repeat this.data -->
<td>
<a>
<!--= on 'click' (emails.drafts.show this.id) -->
<!--= put this.name -->
</a>
</td>
<td>
<small><!--= put this.value --></small>
</td>
<td><!--= put (readable_date this.created_at) --></td>
<td>
<a class='dangerLink u-fontSize--20'>
<!--= on 'click' (confirm (cat 'Are you sure you want to delete draft "' this.name '"?') (emails.drafts.delete this)) -->
<i class='fa fa-times'></i>
</a>
</td>
</tr>
</table>
</div>
<%= render 'settings_modal_footer' %>
</div>

View file

@ -72,9 +72,6 @@
<%= render 'edit_custom_fields_modal' %>
<%= render 'edit_bulk_custom_fields_modal' %>
<%= render 'manage_email_drafts_modal' %>
<%= render 'create_or_update_email_draft_modal' %>
<%= render 'donations/new_offline_modal' %>
<div id='js-vdomParty'></div>

View file

@ -71,10 +71,6 @@ Rails.application.routes.draw do
post(:resend_confirmation)
end
resources(:supporter_emails, only: %i[create show]) do
post(:gmail, on: :collection)
end
resources(:custom_field_masters, only: %i[index create destroy])
resources(:custom_field_joins, only: []) do
post(:modify, on: :collection)

View file

@ -1961,45 +1961,6 @@ CREATE TABLE public.source_tokens (
);
--
-- Name: supporter_emails; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.supporter_emails (
id integer NOT NULL,
"to" text,
"from" character varying(255),
subject character varying(255),
body text,
supporter_id integer,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
nonprofit_id integer,
recipient_count integer,
user_id integer,
gmail_thread_id character varying(255)
);
--
-- Name: supporter_emails_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.supporter_emails_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: supporter_emails_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.supporter_emails_id_seq OWNED BY public.supporter_emails.id;
--
-- Name: supporter_notes; Type: TABLE; Schema: public; Owner: -
--
@ -2750,13 +2711,6 @@ ALTER TABLE ONLY public.roles ALTER COLUMN id SET DEFAULT nextval('public.roles_
ALTER TABLE ONLY public.sessions ALTER COLUMN id SET DEFAULT nextval('public.sessions_id_seq'::regclass);
--
-- Name: supporter_emails id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.supporter_emails ALTER COLUMN id SET DEFAULT nextval('public.supporter_emails_id_seq'::regclass);
--
-- Name: supporter_notes id; Type: DEFAULT; Schema: public; Owner: -
--
@ -3212,14 +3166,6 @@ ALTER TABLE ONLY public.supporters
ADD CONSTRAINT supporter_data_pkey PRIMARY KEY (id);
--
-- Name: supporter_emails supporter_emails_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.supporter_emails
ADD CONSTRAINT supporter_emails_pkey PRIMARY KEY (id);
--
-- Name: supporter_notes supporter_notes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
@ -4339,6 +4285,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20210122184714'),
('20210122203303'),
('20210127193411'),
('20210128215402');
('20210128215402'),
('20210204174909');

View file

@ -0,0 +1,9 @@
# frozen_string_literal: true
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
class RemoveSupporterEmails < ActiveRecord::Migration[6.1]
def change
drop_table :supporter_emails
end
end

View file

@ -141,28 +141,6 @@ module InsertActivities
.where("payments.kind='Dispute'")
end
def self.for_supporter_emails(ids)
insert_supporter_emails_expr
.and_where('supporter_emails.id IN ($ids)', ids: ids)
.execute
end
def self.insert_supporter_emails_expr
Qx.insert_into(:activities, insert_cols.concat(['user_id']))
.select(defaults.concat([
'supporter_emails.supporter_id',
"'SupporterEmail' AS attachment_type",
'supporter_emails.id AS attachment_id',
'supporter_emails.nonprofit_id',
'supporter_emails.created_at AS date',
"json_build_object('gmail_thread_id', supporter_emails.gmail_thread_id, 'subject', supporter_emails.subject, 'from', supporter_emails.from)",
"'SupporterEmail' AS kind",
'users.id AS user_id'
]))
.from(:supporter_emails)
.left_join(:users, 'users.id=supporter_emails.user_id')
end
def self.for_supporter_notes(notes)
notes.map do |note|
note.activities.create(supporter: note.supporter,

View file

@ -6,7 +6,7 @@ module MergeSupporters
# For supporters that have been merged, we want to update all their child tables to the new supporter_id
def self.update_associations(old_supporter_ids, new_supporter_id, np_id, profile_id)
# The new supporter needs to have the following tables from the merged supporters:
associations = %i[activities donations recurring_donations offsite_payments payments tickets supporter_notes supporter_emails full_contact_infos]
associations = %i[activities donations recurring_donations offsite_payments payments tickets supporter_notes full_contact_infos]
associations.each do |table_name|
Qx.update(table_name).set(supporter_id: new_supporter_id).where('supporter_id IN ($ids)', ids: old_supporter_ids).timestamps.execute

View file

@ -1,19 +0,0 @@
# frozen_string_literal: true
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
require 'rails_helper'
require 'controllers/support/shared_user_context'
describe Nonprofits::SupporterEmailsController, type: :controller do
include_context :shared_user_context
describe 'rejects unauthenticated users' do
describe 'create' do
include_context :open_to_np_associate, :post, :create, nonprofit_id: :__our_np
end
describe 'gmail' do
include_context :open_to_np_associate, :post, :gmail, nonprofit_id: :__our_np
end
end
end