From 3446aca7eb5b86232a999d3a49a7bd5b0048073a Mon Sep 17 00:00:00 2001 From: Travis Briggs Date: Sun, 16 Jul 2023 10:18:57 -0700 Subject: [PATCH] Missing file --- wp1/selection/models/book.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/wp1/selection/models/book.py b/wp1/selection/models/book.py index fbc881e5..74cf9f76 100644 --- a/wp1/selection/models/book.py +++ b/wp1/selection/models/book.py @@ -1,4 +1,5 @@ import logging +import urllib import mwparserfromhell import requests @@ -58,7 +59,18 @@ def build(self, content_type, **params): def validate(self, **params): if 'url' not in params: - return ('', '', ['Missing URL parameter']) + return ('', params['url'], ['Missing URL parameter']) + + if 'project' not in params: + return ('', params['url'], ['Missing project parameter']) + + if params['project'] not in params['url']: + parsed_url = urllib.parse.urlparse(params['url']) + return ('', params['url'], [ + 'The domain of your URL does not match your ' + 'selected project (project is: %s, URL has: %s)' % + (params['project'], parsed_url.netloc) + ]) if not validators.url(params['url']): return ('', params['url'], ['That doesn\'t look like a valid URL.'])