From 0d542c7a769b29e6825fec843f8adfed59cbddfd Mon Sep 17 00:00:00 2001 From: Sebastian Marcet Date: Wed, 3 Dec 2014 10:54:42 -0300 Subject: [PATCH] [smarcet] - #7799 * fixes on events/jobs publishing process --- .../services/SapphireEventPublishingService.php | 2 -- events/code/model/EventRegistrationRequestManager.php | 4 ++-- events/js/admin/sangria.page.event.extension.js | 3 +++ .../services/SapphireJobPublishingService.php | 2 -- jobs/code/model/JobRegistrationRequestManager.php | 7 ++++--- jobs/js/admin/sangria.page.job.extension.js | 3 +++ jobs/js/job.registration.form.js | 4 ++++ openstack/code/utils/loggers/Custom_SS_LogEmailWriter.php | 3 +-- 8 files changed, 17 insertions(+), 11 deletions(-) diff --git a/events/code/infrastructure/services/SapphireEventPublishingService.php b/events/code/infrastructure/services/SapphireEventPublishingService.php index e6a0321..4d9a407 100644 --- a/events/code/infrastructure/services/SapphireEventPublishingService.php +++ b/events/code/infrastructure/services/SapphireEventPublishingService.php @@ -25,7 +25,5 @@ final class SapphireEventPublishingService implements IEventPublishingService { $parent = EventHolder::get()->first(); if(!$parent) throw new NotFoundEntityException('EventHolder',''); $event->setParent($parent); // Should set the ID once the Holder is created... - $event->write(); - //$event->doPublish(); } } \ No newline at end of file diff --git a/events/code/model/EventRegistrationRequestManager.php b/events/code/model/EventRegistrationRequestManager.php index 4d823b3..b61f8a6 100644 --- a/events/code/model/EventRegistrationRequestManager.php +++ b/events/code/model/EventRegistrationRequestManager.php @@ -122,7 +122,7 @@ final class EventRegistrationRequestManager { $event = $factory->buildEvent($request); $event_repository->add($event); $request->markAsPosted(); - + $event_publishing_service->publish($event); //send Accepted message $point_of_contact = $request->getPointOfContact(); $name_to = $point_of_contact->getName(); @@ -139,7 +139,7 @@ final class EventRegistrationRequestManager { return $event; }); - $event_publishing_service->publish($event); + return $event; } diff --git a/events/js/admin/sangria.page.event.extension.js b/events/js/admin/sangria.page.event.extension.js index 0c61c7a..e08ca74 100644 --- a/events/js/admin/sangria.page.event.extension.js +++ b/events/js/admin/sangria.page.event.extension.js @@ -120,6 +120,8 @@ jQuery(document).ready(function($) { modal: true, buttons: { "Post": function() { + var btn = $(".ui-dialog-buttonset button:contains('Post')",$(this).parent()); + btn.attr("disabled", true); var id = $(this).data('id'); var row = $(this).data('row'); var url = 'api/v1/event-registration-requests/'+id+'/posted'; @@ -133,6 +135,7 @@ jQuery(document).ready(function($) { }, error: function (jqXHR, textStatus, errorThrown) { ajaxError(jqXHR, textStatus, errorThrown); + btn.attr("disabled", false); } }); $(this).dialog( "close" ); diff --git a/jobs/code/infrastructure/services/SapphireJobPublishingService.php b/jobs/code/infrastructure/services/SapphireJobPublishingService.php index 5b9bcc2..4ef35fc 100644 --- a/jobs/code/infrastructure/services/SapphireJobPublishingService.php +++ b/jobs/code/infrastructure/services/SapphireJobPublishingService.php @@ -25,7 +25,5 @@ implements IJobPublishingService $parent = JobHolder::get()->first(); if(!$parent) throw new NotFoundEntityException('JobHolder',''); $job->setParent($parent); // Should set the ID once the Holder is created... - $job->write(); - //$job->doPublish(); } } \ No newline at end of file diff --git a/jobs/code/model/JobRegistrationRequestManager.php b/jobs/code/model/JobRegistrationRequestManager.php index 04cd35b..ff8e5d1 100644 --- a/jobs/code/model/JobRegistrationRequestManager.php +++ b/jobs/code/model/JobRegistrationRequestManager.php @@ -136,13 +136,15 @@ final class JobRegistrationRequestManager { $repository = $this->repository; $factory = $this->factory; $jobs_repository = $this->jobs_repository; + $jobs_publishing_service = $this->jobs_publishing_service ; - $job = $this->tx_manager->transaction(function() use ($id, $repository, $jobs_repository, $factory, $jobs_link){ + $job = $this->tx_manager->transaction(function() use ($id, $repository, $jobs_repository, $factory, $jobs_link, $jobs_publishing_service){ $request = $repository->getById($id); if(!$request) throw new NotFoundEntityException('JobRegistrationRequest',sprintf('id %s',$id )); $job = $factory->buildJob($request); $jobs_repository->add($job); $request->markAsPosted(); + $jobs_publishing_service->publish($job); //send Accepted message $point_of_contact = $request->getPointOfContact(); $name_to = $point_of_contact->getName(); @@ -155,11 +157,10 @@ final class JobRegistrationRequestManager { 'JobLink' => $jobs_link, )); $email->send(); - return $job; }); - $this->jobs_publishing_service->publish($job); + return $job; } diff --git a/jobs/js/admin/sangria.page.job.extension.js b/jobs/js/admin/sangria.page.job.extension.js index e663212..bd19239 100644 --- a/jobs/js/admin/sangria.page.job.extension.js +++ b/jobs/js/admin/sangria.page.job.extension.js @@ -176,6 +176,8 @@ jQuery(document).ready(function($) { modal: true, buttons: { "Post": function() { + var btn = $(".ui-dialog-buttonset button:contains('Post')",$(this).parent()); + btn.attr("disabled", true); var id = $(this).data('id'); var row = $(this).data('row'); var url = 'api/v1/job-registration-requests/'+id+'/posted'; @@ -189,6 +191,7 @@ jQuery(document).ready(function($) { }, error: function (jqXHR, textStatus, errorThrown) { ajaxError(jqXHR, textStatus, errorThrown); + btn.attr("disabled", false); } }); $(this).dialog( "close" ); diff --git a/jobs/js/job.registration.form.js b/jobs/js/job.registration.form.js index 3fa813a..cafcea3 100644 --- a/jobs/js/job.registration.form.js +++ b/jobs/js/job.registration.form.js @@ -168,6 +168,8 @@ jQuery(document).ready(function($) { $(form).submit(function( event ) { if(job_valid) return; + + $('#JobRegistrationRequestForm_JobRegistrationRequestForm_action_saveJobRegistrationRequest').prop('disabled', true); event.preventDefault(); event.stopPropagation(); @@ -227,9 +229,11 @@ jQuery(document).ready(function($) { cancelProcess:function(){ job_valid = false; ajaxIndicatorStop(); + $('#JobRegistrationRequestForm_JobRegistrationRequestForm_action_saveJobRegistrationRequest').prop('disabled', false); }, errorMessage:function(location){ return 'job location: address ( city:'+location.city+',state: '+location.state+', country:'+location.country+' )'; + $('#JobRegistrationRequestForm_JobRegistrationRequestForm_action_saveJobRegistrationRequest').prop('disabled', false); } }); return false; diff --git a/openstack/code/utils/loggers/Custom_SS_LogEmailWriter.php b/openstack/code/utils/loggers/Custom_SS_LogEmailWriter.php index 996c163..7117c39 100644 --- a/openstack/code/utils/loggers/Custom_SS_LogEmailWriter.php +++ b/openstack/code/utils/loggers/Custom_SS_LogEmailWriter.php @@ -43,8 +43,7 @@ final class Custom_SS_LogEmailWriter extends SS_LogEmailWriter { $formattedData = $this->_formatter->format($event); $subject = $formattedData['subject']; $body = $formattedData['data']; - $email = EmailFactory::getInstance()->buildEmail(self::$send_from, $this->emailAddress,$subject, $body); - + $email = new Email(self::$send_from, $this->emailAddress,$subject, $body); $email->send(); }