Skip to content

Commit

Permalink
[spalenque] - #13508 * add alert when job or news are posted
Browse files Browse the repository at this point in the history
  • Loading branch information
santipalenque committed Nov 15, 2017
1 parent 31b51f5 commit bc2df87
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 7 deletions.
23 changes: 23 additions & 0 deletions jobs/code/model/JobRegistrationRequestManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,27 @@ public function registerJobRegistrationRequest(array $data){
$new_registration_request->registerUser($current_user);
}
$repository->add($new_registration_request);

//send email
$jobs_group = Group::get()->filter('Code','jobs-managers')->first();
$managers_emails = $jobs_group->Members()->column('Email');

$email = EmailFactory::getInstance()->buildEmail(
JOB_SUBMISSION_EMAIL_FROM,
implode(',',$managers_emails),
'New job submission'
);

$email->setTemplate('JobSubmissionEmail');
$email->populateTemplate(array(
'SubmitterName' => $new_registration_request->PointOfContactName,
'SubmitterEmail' => $new_registration_request->PointOfContactEmail,
'JobTitle' => $new_registration_request->Title,
'JobSummary' => $new_registration_request->Description,
'ReviewLink' => Director::absoluteBaseURL().'sangria/ViewJobsDetails'
));

$email->send();
});
}

Expand Down Expand Up @@ -164,6 +185,8 @@ public function postJobRegistrationRequest($id, $jobs_link){

if(empty($name_to) || empty($email_to ))
throw new EntityValidationException(array(array('message'=>'invalid point of contact')));

// email
$email = EmailFactory::getInstance()->buildEmail(JOB_REGISTRATION_REQUEST_EMAIL_FROM, $email_to, "Your OpenStack Job is Now Live");
$email->setTemplate('JobRegistrationRequestAcceptedEmail');
$email->populateTemplate(array(
Expand Down
8 changes: 8 additions & 0 deletions jobs/templates/Layout/JobSubmissionEmail.ss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Submitter
Name: {$SubmitterName}
Email: {$SubmitterEmail}

<h3>{$JobTitle}:</h3>
{$JobSummary}

Review <a href="{$ReviewLink}">here</a>
1 change: 1 addition & 0 deletions migrations/migrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,5 @@ migrations:
- MemberSpammerMigration
- CommunityHelpersMigration
- MemberLinkedInUrlMigration
- CreateJobsManagerGroup

18 changes: 13 additions & 5 deletions news/code/model/NewsRequestManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,22 @@ public function postNews(array $data){
$repository->add($news);

//send email
$email = EmailFactory::getInstance()->buildEmail(NEWS_SUBMISSION_EMAIL_FROM,
NEWS_SUBMISSION_EMAIL_ALERT_TO,
NEWS_SUBMISSION_EMAIL_SUBJECT);
$news_group = Group::get()->filter('Code','news-managers')->first();
$managers_emails = $news_group->Members()->column('Email');

$email = EmailFactory::getInstance()->buildEmail(
NEWS_SUBMISSION_EMAIL_FROM,
implode(',',$managers_emails),
NEWS_SUBMISSION_EMAIL_SUBJECT
);

$email->setTemplate('NewsSubmissionEmail');
$email->populateTemplate(array(
'ArticleHeadline' => $news->Headline,
'ArticleSummary' => $news->Summary
'SubmitterName' => $submitter->FirstName.' '.$submitter->LastName,
'SubmitterEmail' => $submitter->Email,
'ArticleHeadline' => $news->Headline,
'ArticleSummary' => $news->Summary,
'ReviewLink' => Director::absoluteBaseURL().'news-manage'
));

$email->send();
Expand Down
10 changes: 8 additions & 2 deletions news/templates/Layout/Includes/NewsSubmissionEmail.ss
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
<p>{$ArticleHeadline}:</p>
<p>{$ArticleSummary}</p>
Submitter
Name: {$SubmitterName}
Email: {$SubmitterEmail}

<h3>{$ArticleHeadline}:</h3>
{$ArticleSummary}

Review <a href="{$ReviewLink}">here</a>
39 changes: 39 additions & 0 deletions openstack/code/migrations/CreateJobsManagerGroup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/**
* Copyright 2017 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
final class CreateJobsManagerGroup extends AbstractDBMigrationTask
{
protected $title = "Create Jobs managers groups";

protected $description = "creates group jobs-managers";

function doUp()
{
global $database;

$group = new Group();
$group->setTitle('Jobs Managers');
$group->setDescription('Sangria Access and Receives notification when a new job request is posted for review.');
$group->setSlug('jobs-managers');
$group->write();

Permission::grant($group->getIdentifier(), 'SANGRIA_ACCESS');

}

function doDown()
{

}
}
1 change: 1 addition & 0 deletions sample._ss_environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
define('REVOCATION_NOTIFICATION_EMAIL_FROM','');
//used on jobs module.
define('JOB_REGISTRATION_REQUEST_EMAIL_FROM','');
define('JOB_SUBMISSION_EMAIL_FROM','secretary@openstack.org');
//used on openstack/code/summit/TrackChairPage.php (EmailTrackChairs - ln 739)
define('TRACK_CHAIRS_EMAIL_FROM','');
//used on openstack/code/summit/SpeakerListPage.php (EmailSpeakers - ln 59)
Expand Down

0 comments on commit bc2df87

Please sign in to comment.