Page MenuHomePhabricator

Fix resources.Partner.None message when returning an authorization
Closed, ResolvedPublic

Description

Users can return an authorization, expiring it and freeing up a space for other users, on their My Library page. Doing so sends them a system message, which currently appears to be broken. I just returned my Cambridge University Press account and received the message Access to resources.Partner.None has been returned.

The message is added in https://github.com/WikipediaLibrary/TWLight/blob/58553e8d9690ff22f3bd5bf1afe4d6b707a073d7/TWLight/users/views.py#L851.

The issue was likely introduced when we moved to a model whereby Authorizations can have multiple partners. authorization.partners is no longer just a single resource object.

Instead, we could do the following:

_("Access to {} has been returned.").format(authorization.partners.get()),

.get() should always return one resource object because users can't return Bundle authorizations, which is the only case where partners contains multiple resources.

Note this code hasn't been tested - you should verify this does what it's supposed to.

Good first task

This task has been placed in the #good-first-task category. This means it has been scoped and written in a way that makes it simpler for folks who haven’t contributed to the tool’s development or open source software in the past.

If that’s you, welcome! Please feel free to ask questions here about this specific task or the codebase more generally. We’ll be more than happy to help you and clarify the steps needed to complete the task, whether that’s setting up the repository, implementing the necessary changes, or pushing your changes to Github.

If you have experience contributing to this project or similar ones, please consider leaving this one for someone new, and taking a look at the Open Tasks column of the workboard for another task. Also feel free to help out if you see unanswered questions here!

How to contribute

Assign yourself to this task: Click the ‘Add Action’ dropdown menu below and then select Assign / Claim. The box should fill your username in automatically, then click Submit!

To submit your changes, you should fork the repository and create a new branch. After pushing your changes to your Github branch, you can open a pull request. Please link your pull request in a comment here when it has been submitted, and include the Phabricator task number in the pull request. Experienced contributors to the project will review your code and either provide feedback or merge it in!

Event Timeline

Restricted Application added a subscriber: Sadads. · View Herald TranscriptOct 8 2020, 9:53 AM
Yash4357 claimed this task.Oct 8 2020, 5:18 PM
Yash4357 added a subscriber: Yash4357.

I would like to work on this task

Hi Sam,
I have one doubt

I had add these two authorizations which are show in the image from the Django Admin for testing and these are also get expired.
So now, how I can return them to see the message which you have mentioned in the issue.

Hi Sam,
I had created a log in a views.py for debugging but, I don't know that where to see that log because there is no log files generated.
Can you tell me that how I can see my logs??

Hi @Yash4357 You'll need to give the authorizations expiry dates in the future.

@jsn.sherman or @Scardenasmolinar could you chime in on how Yash can access logs he's adding with the logging module?

Hi Sam,

Now, I give a future expiry date, but I don't know how to return this authorization to see the message you mentioned..

The authorizations need to be to resources with the Proxy access method :)

Hi Sam,
I did not understand, what you said?
Please can you elaborate it?

Merged. Thanks for your contribution!

Samwalton9 closed this task as Resolved.Thu, Oct 29, 2:24 PM