Skip to content

Commit

Permalink
PermissionProvider - consolidate to MANAGE_JOBS permission (#15)
Browse files Browse the repository at this point in the history
initial i18n work
  • Loading branch information
jsirish committed May 3, 2019
1 parent 1a05bc6 commit cb2d9ba
Show file tree
Hide file tree
Showing 11 changed files with 267 additions and 225 deletions.
Empty file added lang/_manifest_exclude
Empty file.
69 changes: 69 additions & 0 deletions lang/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
en:
Dynamic\Jobs\Admin\JobAdmin:
MENUTITLE: Jobs

Dynamic\Jobs\Model\JobCategory:
NameDescription: 'For internal reference only'
NameLabel: 'Name'
PLURALNAME: Categories
PLURALS:
one: 'A Category'
other: '{count} Categories'
SINGULARNAME: Category
TitleLabel: 'Title'

Dynamic\Jobs\Model\JobSection:
NameLabel: 'Name'
PLURALNAME: Sections
PLURALS:
one: 'A Section'
other: '{count} Sections'
SINGULARNAME: Section
TitleLabel: 'Title'

Dynamic\Jobs\Model\JobSubmission:
AvailableLabel: 'Date Available'
CreatedLabel: 'Application Date'
ContentLabel: 'Cover Letter'
DESCRIPTION: 'Online job application allowing for a resume upload'
EmailLabel: 'Email'
FirstNameLabel: 'First'
JobLabel: 'Job'
LastNameLabel: 'Last'
NameLabel: 'Applicant'
PhoneLabel: 'Phone'
PLURALNAME: 'Job Applications'
PLURALS:
one: 'A Job Application'
other: '{count} Job Applications'
ResumeLabel: 'Resume'
SINGULARNAME: 'Job Application'

Dynamic\Jobs\Page\Job:
ContentLabel: 'Introduction'
DESCRIPTION: 'Job detail page allowing for application submissions'
DetailsTab: 'Details'
EndPostDateDescription: 'Date position should be removed from website'
EndPostDateLabel: 'Post End Date'
JOB_MANAGE: 'Manage Jobs'
JOB_MANAGE_CATEGORY: 'Jobs'
JOB_MANAGE_HELP: 'Access to add, edit and delete Jobs'
PLURALNAME: Jobs
PLURALS:
one: 'A Job'
other: '{count} Jobs'
PositionTypeLabel: 'Position Type'
PostDateDescription: 'Date position should appear on website'
PostDateLabel: 'Post Start Date'
SectionsDescription: 'ex: Requirements, Education, Duties, etc.'
SINGULARNAME: Job
SubmissionsTab: 'Submissions'
TitleLabel: 'Position Name'

Dynamic\Jobs\Page\JobCollection:
DESCRIPTION: 'Display a list of available jobs'
PLURALNAME: 'Job Holders'
PLURALS:
one: 'A Job Holder'
other: '{count} Job Holders'
SINGULARNAME: 'Job Holder'
39 changes: 24 additions & 15 deletions src/Model/JobCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@
*/
class JobCategory extends DataObject
{
/**
* @var string
*/
private static $singular_name = 'Category';

/**
* @var string
*/
private static $plural_name = 'Categories';

/**
* @var string
*/
Expand Down Expand Up @@ -60,14 +50,33 @@ class JobCategory extends DataObject
'Title',
];

/**
* @param bool $includerelations
* @return array
*/
public function fieldLabels($includerelations = true)
{
$labels = parent::fieldLabels($includerelations);

$labels['Name'] = _t(__CLASS__ . '.NameLabel', 'Name');
$labels['Title'] = _t(__CLASS__ . '.TitleLabel', 'Title');
$labels['Jobs'] = _t(Job::class . '.PLURALNAME', 'Jobs');

return $labels;
}

/**
* @return FieldList
*/
public function getCMSFields()
{
$fields = parent::getCMSFields();

$fields->dataFieldByName('Name')->setDescription('For internal reference only');
$fields->dataFieldByName('Name')
->setDescription(_t(
__CLASS__ . '.NameDescription',
'For internal reference only'
));

if ($this->ID) {
$fields->dataFieldByName('Jobs')->getConfig()
Expand All @@ -84,7 +93,7 @@ public function getCMSFields()
*/
public function canEdit($member = null)
{
return Permission::check('Job_EDIT', 'any', $member);
return Permission::check('JOB_MANAGE', 'any', $member);
}

/**
Expand All @@ -94,7 +103,7 @@ public function canEdit($member = null)
*/
public function canDelete($member = null)
{
return Permission::check('Job_DELETE', 'any', $member);
return Permission::check('JOB_MANAGE', 'any', $member);
}

/**
Expand All @@ -104,7 +113,7 @@ public function canDelete($member = null)
*/
public function canCreate($member = null, $context = [])
{
return Permission::check('Job_CREATE', 'any', $member);
return Permission::check('JOB_MANAGE', 'any', $member);
}

/**
Expand All @@ -114,6 +123,6 @@ public function canCreate($member = null, $context = [])
*/
public function canView($member = null)
{
return true;
return Permission::check('JOB_MANAGE', 'any', $member);
}
}
32 changes: 18 additions & 14 deletions src/Model/JobSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@
*/
class JobSection extends DataObject
{
/**
* @var string
*/
private static $singular_name = 'Section';

/**
* @var string
*/
private static $plural_name = 'Sections';

/**
* @var string
*/
Expand Down Expand Up @@ -68,6 +58,20 @@ class JobSection extends DataObject
'Content',
];

/**
* @param bool $includerelations
* @return array
*/
public function fieldLabels($includerelations = true)
{
$labels = parent::fieldLabels($includerelations);

$labels['Name'] = _t(__CLASS__ . '.NameLabel', 'Name');
$labels['Title'] = _t(__CLASS__ . '.TitleLabel', 'Title');

return $labels;
}

/**
* @return FieldList
*/
Expand Down Expand Up @@ -106,7 +110,7 @@ public function validate()
*/
public function canEdit($member = null)
{
return Permission::check('Job_EDIT', 'any', $member);
return Permission::check('JOB_MANAGE', 'any', $member);
}

/**
Expand All @@ -116,7 +120,7 @@ public function canEdit($member = null)
*/
public function canDelete($member = null)
{
return Permission::check('Job_DELETE', 'any', $member);
return Permission::check('JOB_MANAGE', 'any', $member);
}

/**
Expand All @@ -126,7 +130,7 @@ public function canDelete($member = null)
*/
public function canCreate($member = null, $context = [])
{
return Permission::check('Job_CREATE', 'any', $member);
return Permission::check('JOB_MANAGE', 'any', $member);
}

/**
Expand All @@ -136,6 +140,6 @@ public function canCreate($member = null, $context = [])
*/
public function canView($member = null)
{
return true;
return Permission::check('JOB_MANAGE', 'any', $member);
}
}
85 changes: 43 additions & 42 deletions src/Model/JobSubmission.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,6 @@
*/
class JobSubmission extends DataObject
{
/**
* @var string
*/
private static $singular_name = 'Job Application';

/**
* @var string
*/
private static $plural_name = 'Job Applications';

/**
* @var string
*/
private static $description = 'Online job application allowing for a resume upload';

/**
* @var string
*/
Expand Down Expand Up @@ -73,35 +58,47 @@ class JobSubmission extends DataObject
* @var array
*/
private static $summary_fields = [
'Name' => 'Applicant',
'Job.Title' => 'Job',
'Created.Nice' => 'Date',
'Name',
'Job.Title',
'Created.Nice',
];

/**
* @var array
*/
private static $searchable_fields = [
'FirstName' => [
'title' => 'First',
],
'LastName' => [
'title' => 'Last',
],
'Job.ID' => [
'title' => 'Job',
],
'Email' => [
'title' => 'Email',
],
'Phone' => [
'title' => 'Phone',
],
'Content' => [
'title' => 'Cover Letter',
],
'FirstName',
'LastName',
'Job.ID',
'Email',
'Phone',
'Content',
];

/**
* @param bool $includerelations
* @return array
*/
public function fieldLabels($includerelations = true)
{
$labels = parent::fieldLabels($includerelations);

$labels['Name'] = _t(__CLASS__ . '.NameLabel', 'Applicant');
$labels['Job.Title'] = _t(__CLASS__ . '.JobLabel', 'Job');
$labels['Job.ID'] = _t(__CLASS__ . '.JobLabel', 'Job');
$labels['Created'] = _t(__CLASS__ . '.CreatedLabel', 'Application Date');
$labels['Created.Nice'] = _t(__CLASS__ . '.CreatedLabel', 'Application Date');
$labels['FirstName'] = _t(__CLASS__ . '.FirstNameLabel', 'First');
$labels['LastName'] = _t(__CLASS__ . '.LastNameLabel', 'Last');
$labels['Email'] = _t(__CLASS__ . '.EmailLabel', 'Email');
$labels['Phone'] = _t(__CLASS__ . '.PhoneLabel', 'Phone');
$labels['Available'] = _t(__CLASS__ . '.AvailableLabel', 'Date Available');
$labels['Resume'] = _t(__CLASS__ . '.ResumeLabel', 'Resume');
$labels['Content'] = _t(__CLASS__ . '.ContentLabel', 'Cover Letter');

return $labels;
}

/**
* @return string
*/
Expand Down Expand Up @@ -184,12 +181,16 @@ public function getCMSFields()
]);

$fields->insertBefore(
ReadonlyField::create('JobTitle', 'Job', $this->Job()->getTitle()),
ReadonlyField::create('JobTitle', $this->fieldLabel('Job.Title'), $this->Job()->getTitle()),
'Content'
);

$fields->insertBefore(
ReadonlyField::create('Created', 'Application Date', $this->dbObject('Created')->FormatFromSettings()),
ReadonlyField::create(
'Created',
$this->fieldLabel('Created'),
$this->dbObject('Created')->FormatFromSettings()
),
'Content'
);

Expand Down Expand Up @@ -219,7 +220,7 @@ public function getEditLink()
*/
public function canEdit($member = null)
{
return Permission::check('Job_EDIT', 'any', $member);
return Permission::check('JOB_MANAGE', 'any', $member);
}

/**
Expand All @@ -229,7 +230,7 @@ public function canEdit($member = null)
*/
public function canDelete($member = null)
{
return Permission::check('Job_DELETE', 'any', $member);
return Permission::check('JOB_MANAGE', 'any', $member);
}

/**
Expand All @@ -239,7 +240,7 @@ public function canDelete($member = null)
*/
public function canCreate($member = null, $contect = [])
{
return Permission::check('Job_CREATE', 'any', $member);
return Permission::check('JOB_MANAGE', 'any', $member);
}

/**
Expand All @@ -249,6 +250,6 @@ public function canCreate($member = null, $contect = [])
*/
public function canView($member = null)
{
return true;
return Permission::check('JOB_MANAGE', 'any', $member);
}
}
Loading

0 comments on commit cb2d9ba

Please sign in to comment.