Skip to content

Commit

Permalink
Missing file
Browse files Browse the repository at this point in the history
  • Loading branch information
audiodude committed Jul 16, 2023
1 parent d1fa97a commit 3446aca
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion wp1/selection/models/book.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import urllib

import mwparserfromhell
import requests
Expand Down Expand Up @@ -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.'])
Expand Down

0 comments on commit 3446aca

Please sign in to comment.