Page MenuHomePhabricator

Add admin validation ensuring that Partners set to the Proxy or Library Bundle access methods have a target_url
Closed, ResolvedPublic

Description

Task

In the admin interface, users shouldn't be allowed to save a partner with the Proxy or Library Bundle access method which has no target_url set.

In Django, these validations are defined in a model's clean function. For Partner objects, that can be found in models.py at https://github.com/WikipediaLibrary/TWLight/blob/master/TWLight/resources/models.py#L396.

To solve this task, add a new if statement to this function which, if the object has the PROXY or BUNDLE access methods, verifies that it also has target_url data. If it doesn't, a ValidationError should be raised stating "Proxy and Bundle partners require a target URL".

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

Samwalton9-WMF renamed this task from Add additional validation on resources to Add admin validation ensuring that Partners set to the Proxy or Library Bundle access methods have a target_url.Aug 7 2020, 8:08 AM
Samwalton9-WMF updated the task description. (Show Details)

I have made a minor fix. If this is useful, this task can be closed.

I have submitted the PR. Task closed.

ThesenatorO5-2 changed the point value for this task from 70 to 95.Aug 13 2020, 3:55 AM

Thanks for the pull request! (https://github.com/WikipediaLibrary/TWLight/pull/505)

This task should remain open until the changes are merged.

Aklapper removed the point value for this task.

Hello! I am setting up the project, will raise a pull request soon

Great, let me know if you have any questions :)

I have tried to setup the project locally and stuck in the following step

Screenshot from 2020-09-30 17-09-35.png (819×1 px, 178 KB)

Tried to look into the issues and found that it is similar to https://github.com/WikipediaLibrary/TWLight/issues/372

My system

  • OS: Ubuntu 20.04.1 LTS (Focal Fossa)
  • docker version: 19.03.8
  • docker-compose version: 1.27.4

Thanks @Samwalton9 I have tried to implement the solution but did not succeed because there is no docker-desktop available for Ubuntu and I could not find a way to implement this without that. But later on I tried the setup process again with an older version of docker-compose and it worked finally. I will raise a pull request soon now :)

Oh right - my mistake - I didn't notice you were using Ubuntu and that solution was for Windows. I'm glad to hear you figured it out!

jsn.sherman subscribed.

PR merged. Thanks for your contribution!