Skip to content

Commit 7b14e73

Browse files
committed
Admins can manage sponsors, and other admin UX changes
Summary: * New "Manage Sponsors" section in the admin area * Other UX updates in the admin area Resolves T239, T227, T240 Test Plan: * Check the Manage Sponsors screen * Make sure you can update the status of a sponsor * Check rest of admin area against [the mockups](https://opengovfoundation.github.io/madison-mockups/admin/sponsors.html) Reviewers: doshitan Reviewed By: doshitan Maniphest Tasks: T240, T239, T227 Differential Revision: https://phabricator.opengovfoundation.org/D140
1 parent e95b20e commit 7b14e73

File tree

20 files changed

+314
-129
lines changed

20 files changed

+314
-129
lines changed

app/Http/Controllers/AdminController.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use App\Models\Setting;
88
use App\Models\User;
99
use App\Models\Role;
10+
use App\Models\Sponsor;
1011
use App\Http\Requests\Admin as Requests;
1112
use SiteConfigSaver;
1213

@@ -20,7 +21,23 @@ public function __construct()
2021
public function usersIndex(Requests\Users\Index $request)
2122
{
2223
$users = User::all();
23-
return view('users.list', compact('users'));
24+
return view('admin.manage-users', compact('users'));
25+
}
26+
27+
public function sponsorsIndex(Requests\Sponsors\Index $request)
28+
{
29+
$limit = $request->input('limit', 10);
30+
$sponsors = Sponsor::paginate($limit);
31+
return view('admin.manage-sponsors', compact('sponsors'));
32+
}
33+
34+
public function sponsorsPutStatus(Requests\Sponsors\PutStatus $request, Sponsor $sponsor)
35+
{
36+
$sponsor->status = $request->input('status');
37+
$sponsor->save();
38+
39+
flash(trans('messages.sponsor.status_updated'));
40+
return redirect()->route('admin.sponsors.index');
2441
}
2542

2643
public function usersPostAdmin(Requests\Users\PostAdmin $request, User $user)
@@ -88,12 +105,18 @@ public function siteSettingsIndex(Requests\SiteSettings\Index $request)
88105
}
89106
}
90107

108+
// We have to put the key into the desc properties since `groupBy` gets rid of them
109+
$groupedSettingsDesc = collect($allSettingsDesc)->map(function ($setting, $key) {
110+
$setting['key'] = $key;
111+
return $setting;
112+
})->groupBy('group');
113+
91114
// reset config() to full settings
92115
(new \App\Config\Bootstrap\LoadConfiguration())
93116
->bootstrap(app());
94117

95118
return view('admin.site-settings', compact([
96-
'allSettingsDesc',
119+
'groupedSettingsDesc',
97120
'currentSettings',
98121
'options',
99122
]));
@@ -231,14 +254,17 @@ public static function getSiteSettingKeys()
231254
{
232255
return [
233256
'madison.date_format' => [
257+
'group' => 'date_time',
234258
'type' => 'select',
235259
'choices' => static::validDateFormats(),
236260
],
237261
'madison.time_format' => [
262+
'group' => 'date_time',
238263
'type' => 'select',
239264
'choices' => static::validTimeFormats(),
240265
],
241266
'madison.google_analytics_property_id' => [
267+
'group' => 'google_analytics',
242268
'type' => 'text',
243269
],
244270
];

app/Http/Controllers/SponsorController.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,6 @@ public function update(Requests\Update $request, Sponsor $sponsor)
103103
}
104104
}
105105

106-
public function updateStatus(Requests\UpdateStatus $request, Sponsor $sponsor)
107-
{
108-
$sponsor->status = $request->input('status');
109-
$sponsor->save();
110-
111-
flash(trans('messages.sponsor.status_updated'));
112-
return redirect()->route('sponsors.index', ['sponsor' => $sponsor->id]);
113-
}
114-
115106
/**
116107
* Lists documents for a given sponsor.
117108
*/
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace App\Http\Requests\Admin\Sponsors;
4+
5+
use App\Http\Requests\AdminRequest;
6+
7+
class Index extends AdminRequest
8+
{
9+
/**
10+
* Get the validation rules that apply to the request.
11+
*
12+
* @return array
13+
*/
14+
public function rules()
15+
{
16+
return [
17+
//
18+
];
19+
}
20+
21+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace App\Http\Requests\Admin\Sponsors;
4+
5+
use App\Models\Sponsor;
6+
use App\Http\Requests\AdminRequest;
7+
8+
class PutStatus extends AdminRequest
9+
{
10+
public function rules()
11+
{
12+
return [
13+
'status' => 'in:' . implode(',', Sponsor::getStatuses()),
14+
];
15+
}
16+
}

app/Http/Requests/Sponsor/UpdateStatus.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

app/Notifications/AddedToSponsor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function via($notifiable)
4242
*/
4343
public function toMail($notifiable)
4444
{
45-
$url = route('sponsors.index', ['id' => [$this->sponsorMember->sponsor->id]]);
45+
$url = route('sponsors.documents.index', $this->sponsorMember->sponsor);
4646

4747
return (new MailMessage)
4848
->subject(trans(static::baseMessageLocation().'.added_to_sponsor', [

app/Notifications/SponsorNeedsApproval.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function via($notifiable)
4242
*/
4343
public function toMail($notifiable)
4444
{
45-
$url = route('sponsors.index', ['all' => 'true', 'id' => [$this->sponsor->id]]);
45+
$url = route('admin.sponsors.index');
4646

4747
return (new MailMessage)
4848
->subject(trans(static::baseMessageLocation().'.subject', ['name' => $this->sponsor->name]))

resources/assets/js/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $(function () {
1515
});
1616

1717
$.fn.select2.defaults.set('theme', 'bootstrap');
18-
$('select').select2();
18+
$('select:not(.no-select2)').select2();
1919
});
2020

2121
window.loadTranslations = function (msgIds) {

resources/lang/en/messages.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@
224224

225225
'status' => 'Status',
226226
'statuses' => [
227-
\App\Models\Sponsor::STATUS_ACTIVE => 'Active',
227+
\App\Models\Sponsor::STATUS_ACTIVE => 'Approved',
228228
\App\Models\Sponsor::STATUS_PENDING => 'Pending',
229229
],
230230

@@ -403,16 +403,21 @@
403403
'admin_label' => 'Site Administration: :page',
404404
'featured_documents' => 'Featured Documents',
405405
'manage_users' => 'Manage Users',
406+
'manage_sponsors' => 'Manage Sponsors',
406407
'updated_featured_documents' => 'Feature documents updated',
407408
'site_settings' => 'Site Settings',
408409
'custom_pages' => 'Custom Pages',
409410
'pages' => 'Pages',
410411
'add_featured_document' => 'Add Featured Document',
411412

413+
'setting_groups' => [
414+
'date_time' => 'Date & Time',
415+
'google_analytics' => 'Google Analytics',
416+
],
412417
'madison' => [
413418
'date_format' => 'Date Format',
414419
'time_format' => 'Time Format',
415-
'google_analytics_property_id' => 'Google Analytics Property Id',
420+
'google_analytics_property_id' => 'Google Analytics Key',
416421
'google_analytics_property_id_help' => 'The UA-XXXXX-Y string identifying which Google Analytics property you wish to track traffic against',
417422
],
418423
],
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@extends('layouts.app')
2+
3+
@section('pageTitle', trans('messages.admin.manage_sponsors'))
4+
5+
@section('content')
6+
<div class="page-header">
7+
<h1>{{ trans('messages.sponsor.list') }}</h1>
8+
@include('components.breadcrumbs.admin')
9+
</div>
10+
11+
@include('components.errors')
12+
13+
<div class="row">
14+
@include('admin.partials.admin-sidebar')
15+
16+
<div class="col-md-9">
17+
@include('sponsors.partials.table', ['sponsors' => $sponsors])
18+
</div>
19+
</div>
20+
@endsection

0 commit comments

Comments
 (0)