Skip to content

Xsrust/mvp#523

Merged
briri merged 7 commits intoDMPRoadmap:CDL-MVPfrom
DigitalCurationCentre:xsrust/mvp
Jul 21, 2017
Merged

Xsrust/mvp#523
briri merged 7 commits intoDMPRoadmap:CDL-MVPfrom
DigitalCurationCentre:xsrust/mvp

Conversation

@xsrust
Copy link
Contributor

@xsrust xsrust commented Jul 20, 2017

Addresses #242, with implementation as detailed in the ticket

Note: this code will require a db migration to add the 'active' flag to the roles table

@xsrust
Copy link
Contributor Author

xsrust commented Jul 20, 2017

Forgot to check out a new branch before committing changes for #492.

So now this PR includes the work for public DMP export with multiple phases

redirect_to controller: 'plans', action: 'share', id: @role.plan.id
end

def archive
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not 100% on the archive action name for this. Perhaps deactivate is a bit clearer on what it does - "remove" is certainly not accurate (even though it eventually refers to "remove plan" action)

Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps "hide" or "disable" would be more appropriate? Also add a comment that summarizes what its doing: "Removes the plan from the user's list in the UI. The user's relationship to the plan does not change within the database"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll update the name tomorrow morning.
Good catch on the lack of comment, I'll add a small block describing the functionality

@role.plan.owned_by?(@user.id)
end

def archive?
Copy link
Contributor

Choose a reason for hiding this comment

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

Again not 100% sold on the name

<!-- if the user has projects -->
<p>
<% if @plans.count > 0 %>
<% if @plans.length > 0 %>
Copy link
Contributor

Choose a reason for hiding this comment

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

good change.

config/routes.rb Outdated
resources :roles, only: [:create, :update, :destroy]
resources :roles, only: [:create, :update, :destroy] do
member do
put :archive
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment about action name.

Copy link
Contributor

@briri briri left a comment

Choose a reason for hiding this comment

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

We should add tests for this later on when we reevaluate our test coverage

redirect_to controller: 'plans', action: 'share', id: @role.plan.id
end

def archive
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps "hide" or "disable" would be more appropriate? Also add a comment that summarizes what its doing: "Removes the plan from the user's list in the UI. The user's relationship to the plan does not change within the database"

end

def set_defaults
self.active = true if self.new_record?
Copy link
Contributor

Choose a reason for hiding this comment

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

nice. I have been using self.id.nil?. I like new_record? better and will start using it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. stole it from some guy's blog on best practices for setting defaults in rails


def show?
@plan.readable_by?(@user.id)
@plan.readable_by?(@user.id) && Role.find_by(user_id: @user.id, plan_id: @plan.id).active
Copy link
Contributor

Choose a reason for hiding this comment

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

It makes sense to keep this active check out of the readable_by? method. Is the check necessary though? These plans are filtered out of the user's dashboard, so the likelihood of them hitting these policy checks is slim. Even if they did via a bookmark or something, they should technically be able to access them.

This is maybe a discussion for a separate ticket though. I could see use cases where we would send them to these endpoints to view the plan and restore/unhide them if we decide to offer that option.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The check is probably not needed, but If a user removes themself from a plan, and other users cant see that they can access the plan, I like ensuring that behavior in code.

@xsrust
Copy link
Contributor Author

xsrust commented Jul 20, 2017

Just realized while reading over your comments that I didn't filter the 'share plan' page to remove the roles which are not active. I'll add that, make the recommended changes, and update the PR.

@briri
Copy link
Contributor

briri commented Jul 21, 2017

looks good @xsrust

@briri briri merged commit 10a867b into DMPRoadmap:CDL-MVP Jul 21, 2017
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.

3 participants