Skip to content

Commit

Permalink
Merge pull request #1057 from PlanoramaEvents/development
Browse files Browse the repository at this point in the history
3.6.0-rc1
  • Loading branch information
balen authored Jun 6, 2024
2 parents 8ea699f + 29e2772 commit 378e4b3
Show file tree
Hide file tree
Showing 60 changed files with 1,807 additions and 196 deletions.
4 changes: 2 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def check_up
if ScheduleSnapshot.where("status = 'in_progress'").count > 0
redirect_to '/maintenance.html', status: 503
end
# Stop people from making changes if we are publishing
if PublicationStatus.where("status = 'inprogress'").count > 0
# Stop people from making changes if we are running any long job
if JobStatus.where("status = 'inprogress'").count > 0
redirect_to '/maintenance.html', status: 503
end
end
Expand Down
23 changes: 20 additions & 3 deletions app/controllers/concerns/resource_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,17 @@ def collection

@per_page, @current_page, @filters = collection_params


q = if select_fields
select_fields
else
policy_scope(base, policy_scope_class: policy_scope_class)
end

if default_scope(query: q)
q = default_scope(query: q)
end

q = q.includes(includes)
.references(references)
.eager_load(eager_load)
Expand All @@ -243,7 +249,7 @@ def collection
.where(collection_where)
# anpther where?

q = q.distinct if join_tables && !join_tables.empty?
q = q.distinct if (join_tables && !join_tables.empty?) || make_distinct?

q = q.order(order_string)

Expand All @@ -255,8 +261,11 @@ def collection

# TODO we need the size without the query
if paginated
@full_collection_total = policy_scope(base, policy_scope_class: policy_scope_class)
.where(exclude_deleted_clause)
fq = policy_scope(base, policy_scope_class: policy_scope_class)
if default_scope(query: fq)
fq = default_scope(query: fq)
end
@full_collection_total = fq.where(exclude_deleted_clause)
.includes(includes)
.references(references)
.eager_load(eager_load)
Expand Down Expand Up @@ -527,6 +536,10 @@ def select_fields
nil
end

def default_scope(query: nil)
nil
end

def model_name
"#{model_class}"
end
Expand Down Expand Up @@ -749,6 +762,10 @@ def array_col?(col_name:)
false
end

def make_distinct?
false
end

def permitted_params()
_permitted_params(model: nil)
end
Expand Down
101 changes: 101 additions & 0 deletions app/controllers/person_sync_data_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
class PersonSyncDataController < ResourceController
SERIALIZER_CLASS = 'PersonSyncDatumSerializer'.freeze
POLICY_CLASS = 'PersonSyncDatumPolicy'.freeze
POLICY_SCOPE_CLASS = 'PersonSyncDatumPolicy::Scope'.freeze
DEFAULT_SORTBY = 'name_sort_by'
DEFAULT_ORDER = 'asc'.freeze

#
#
#
def match
model_class.transaction do
authorize model_class, policy_class: policy_class

reg_id = params[:reg_id] if params[:reg_id]
person_id = params[:person_id] if params[:person_id]

# one of 'assisted' or 'manual'
reg_match = params[:reg_match] if params[:reg_match]

raise "Type of match should be 'assisted' or 'manual' you gave '#{reg_match}'" unless ['assisted', 'manual'].include? reg_match
raise "No reg id, person id, or match type specified" unless reg_id && person_id && reg_match

# Get the reg sync data
datum = RegistrationSyncDatum.find_by reg_id: reg_id

# Get the person
person = Person.find person_id

# Update the person with the reg data
IdentityService.clear_person_reg_info(person: person);
IdentityService.update_reg_info(person: person, details: datum.raw_info, reg_match: reg_match)

render status: :ok,
json: { message: "Matched" }.to_json,
content_type: 'application/json'
end
end

#
# Method to dismiss a match
# POST request, parameters are reg_id and person_id
#
def dismiss_match
model_class.transaction do
authorize model_class, policy_class: policy_class

reg_id = params[:reg_id] if params[:reg_id]
person_id = params[:person_id] if params[:person_id]

raise "No reg id or person id specified" unless reg_id && person_id

existing = DismissedRegSyncMatch.find_by reg_id: reg_id, person_id: person_id

if !existing
DismissedRegSyncMatch.create!({
reg_id: reg_id,
person_id: person_id
})
end

render status: :ok,
json: { message: "Dismissed Match" }.to_json,
content_type: 'application/json'
end
end

# by default get the data that is not already mapped to a person
def default_scope(query: nil)
return nil unless query

# People that have a potential mapping and not already mapped
query.joins(:registration_sync_data)
.where('people.reg_id is null')
.where('registration_sync_data.reg_id in (select reg_id from registration_map_counts)')
end

def select_fields
PersonSyncDatum.select(
::PersonSyncDatum.arel_table[Arel.star],
'name_sort_by'
)
end

def serializer_includes
[
:registration_sync_data
]
end

def make_distinct?
true
end

def includes
[
:email_addresses,
:registration_sync_data
]
end
end
63 changes: 63 additions & 0 deletions app/controllers/registration_sync_data_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
class RegistrationSyncDataController < ResourceController
SERIALIZER_CLASS = 'RegistrationSyncDatumSerializer'.freeze
POLICY_CLASS = 'RegistrationSyncDatumPolicy'.freeze
POLICY_SCOPE_CLASS = 'RegistrationSyncDatumPolicy::Scope'.freeze
DEFAULT_SORTBY = 'registration_sync_data.name'
DEFAULT_ORDER = 'asc'.freeze

def sync_statistics
authorize current_person, policy_class: policy_class
status = RegistrationSyncStatus.order('created_at desc').first

result = status ? status.result : {}

render status: :ok, json: result.to_json, content_type: 'application/json'
end

def synchronize
authorize current_person, policy_class: policy_class

status = RegistrationSyncStatus.order('created_at desc').first
status = RegistrationSyncStatus.new if status == nil
if status.status != 'inprogress'
status.status = 'inprogress'
status.save!

RegistrationSyncWorker.perform_async
end

render status: :ok, json: {}.to_json, content_type: 'application/json'
end

def people
authorize model_class, policy_class: policy_class
datum = RegistrationSyncDatum.find params[:registration_sync_datum_id]

people = datum.people
options = {
params: {
domain: "#{request.base_url}",
current_person: current_person
}
}

# return the list of people associated with this datum
render json: PersonSerializer.new(people,options).serializable_hash(),
content_type: 'application/json'
end

def serializer_includes
[
:matched_person
]
end

# # by default get the data that is not already mapped to a person
# def default_scope(query: nil)
# return nil unless query

# # People that have a potential mapping and not already mapped
# query.where('reg_id not in (select reg_id from people where reg_id is not null)')
# .where('reg_id in (select reg_id from registration_map_counts)')
# end
end
41 changes: 41 additions & 0 deletions app/javascript/administration/admin_registrations.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<template>
<div class="container-fluid scrollable">
<h1>Registration Sync Management</h1>
<b-button variant="primary" size="sm" v-b-modal.confirm-reg-sync>Registration Synchronize</b-button>
<!-- -->
<!-- <h2>Registration Info (from Reg/clyde)</h2> -->
<person-sync-table></person-sync-table>

<!-- -->
<plano-modal id="confirm-reg-sync" @ok="synchronizeSchedule()">
<template #modal-title>Synchonize Registration Info</template>
</plano-modal>
</div>
</template>

<script>
import PlanoModal from '@/components/plano_modal.vue';
import { toastMixin } from '@/mixins';
import { http } from '@/http';
import PersonSyncTable from "@/registrations/person_sync_table.vue"
export default {
name: "AdminRegistrations",
components: {
PlanoModal,
PersonSyncTable
},
mixins: [
toastMixin
],
methods: {
synchronizeSchedule() {
this.toastPromise(http.get('/registration_sync_data/synchronize'), "Succesfully requested registration sync")
},
},
}
</script>

<style>
</style>
13 changes: 4 additions & 9 deletions app/javascript/administration/playground_component.vue
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
<template>
<div class="container-fluid scrollable">
<h1>Preview features</h1>
<h2>TwoSidedMultiSelect</h2>
<div class="w-75">
<two-sided-multi-select v-model="multiSelectValue" :options="multiSelectOptions"></two-sided-multi-select>
<pre>
value: {{ multiSelectValue }}
</pre>
</div>
<h2>Registration Info (from Reg/clyde)</h2>
<person-sync-table></person-sync-table>
</div>
</template>

<script>
import TwoSidedMultiSelect from "@/components/two_sided_multi_select.vue";
import PersonSyncTable from "@/registrations/person_sync_table.vue"
export default {
name: "PlayGroundComponent",
components: {
TwoSidedMultiSelect
PersonSyncTable
},
data: () => ({
multiSelectOptions: ["one", "two", "three", "four", "five", "six"],
Expand Down
10 changes: 10 additions & 0 deletions app/javascript/app.router.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const loginRoutes = [
import AdminComponent from './administration/admin_component.vue';
import AdminConfigurationsComponent from './administration/admin_configurations.vue';

import AdminRegistrationsComponent from './administration/admin_registrations.vue';

import PlayGroundComponent from './administration/playground_component.vue';

// people
Expand Down Expand Up @@ -168,6 +170,14 @@ export const router = new VueRouter({
requiresAuth: true
}
},
{
path: '/admin-registrations',
component: AdminRegistrationsComponent,
meta: {
requiresAdmin: true,
requiresAuth: true
}
},
{
path: '/people',
component: PeopleScreen,
Expand Down
Loading

0 comments on commit 378e4b3

Please sign in to comment.