Skip to content

Campaign lock and unlock#499

Merged
tonysurma merged 7 commits into
HTBox:masterfrom
stevejgordon:feature/#39-CampaignLockUnlock
Feb 18, 2016
Merged

Campaign lock and unlock#499
tonysurma merged 7 commits into
HTBox:masterfrom
stevejgordon:feature/#39-CampaignLockUnlock

Conversation

@stevejgordon
Copy link
Copy Markdown
Member

Fixes #39

I've taken the approach to add a bool to the campaign model to mark it as locked.
SiteAdmins can lock/unlock any campaign from the details page using the button I've added.
OrgAdmins will see a message stating the campaign has been locked.
In the admin campaign lister I have added a warning icon to locked campaigns
In the public lister, locked campaigns are not shown
API updated to also not display locked campaigns

Hopefully that makes sense and meets the requirement?

@mmoore99
Copy link
Copy Markdown
Contributor

@stevejgordon since the home page has been modified to display a list of current/upcoming campaigns in #417, the Home/Index action will need to be modified to ignore locked campaigns.

return View(_dataAccess.Campaigns.Where(c => c.EndDateTime.UtcDateTime.Date > DateTime.UtcNow.Date).ToViewModel().OrderBy(vm => vm.EndDate).ToList());

@stevejgordon
Copy link
Copy Markdown
Member Author

@mmoore99 Thanks Mike. Good catch.

@tonysurma
Copy link
Copy Markdown
Member

@MisterJames can someone look over this PR before I merge?

<a asp-controller="Campaign" asp-action="Delete" asp-route-area="Admin" asp-route-id="@Model.Id" class="btn btn-default inline-form"><i class="glyphicon glyphicon-trash"></i></a>
@if (User.IsUserType(UserType.SiteAdmin))
{
<form asp-controller="Campaign" asp-route-area="Admin" asp-action="LockUnlock" class="inline-form">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this have to be a form? Seems like a lot of extra code. You are already validating that the logged-in user is a SiteAdmin in CampaignController.LockUnlock

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On this one it's not presenting any other page or input via a http get so I felt it best practice to make this require a http post to the action via a form. If we make it just a hyperlink we potentially should add a page to confirm that we want to lock or unlock the campaign which felt unnecessary.

@mheggeseth
Copy link
Copy Markdown
Contributor

Couple other issues:

  • Activities in locked campaigns are still publicly accessible.
  • The UI should do a bit better job explaining what "locked" means.

@stevejgordon
Copy link
Copy Markdown
Member Author

@mheggeseth Thanks for your feedback. I'll get the changes made ASAP.

@stevejgordon
Copy link
Copy Markdown
Member Author

@mheggeseth I worked on this before work this morning and have most of it ready. I want to do a little more before updating the PR. Did you have any thoughts on what we should display in the UI to explain the locked status?

@mheggeseth
Copy link
Copy Markdown
Contributor

I was thinking a simple tooltip something like "This campaign has been locked by a site administrator. Locked campaigns are not visible to the public or to volunteers."

Also, just reading this phrasing makes me think a site admin should enter a comment/reason for locking the campaign. Otherwise, the org admin is in the dark and doesn't know if/what they should change about the campaign. This could be a separate PR.

@stevejgordon stevejgordon force-pushed the feature/#39-CampaignLockUnlock branch from 65c2819 to 8cd0c56 Compare February 10, 2016 06:58
@stevejgordon
Copy link
Copy Markdown
Member Author

@mheggeseth I've pushed an update which address the above feedback. I've left the form for now unless you think we should just use a hyperlink and post action? I plan to open a new issue later for your thoughts on a lock comment etc.

.Include(a => a.Tasks)
.Include(a => a.RequiredSkills)
.Include(a => a.UsersSignedUp)
.Where(a => !a.Campaign.Locked)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize this only has one referrer in ActivityApiController but it doesn't feel quite right to exclude locked activities before returning from the repository class. I'd rather see those locked activities filtered out in ActivityApiController.

@mheggeseth
Copy link
Copy Markdown
Contributor

I had one comment on some code that you added to IAllReadyDataAccess.Activities. Everything else looks good.

@stevejgordon
Copy link
Copy Markdown
Member Author

@mheggeseth Thanks again for the feedback. Good point and I've updated the PR.

@mheggeseth
Copy link
Copy Markdown
Contributor

Looks good. :shipit:

tonysurma added a commit that referenced this pull request Feb 18, 2016
@tonysurma tonysurma merged commit 0958e1d into HTBox:master Feb 18, 2016
@stevejgordon stevejgordon deleted the feature/#39-CampaignLockUnlock branch June 20, 2016 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants