Revision cb618cc0
b/snf-astakos-app/astakos/oa2/management/commands/oauth2-client-add.py | ||
---|---|---|
39 | 39 |
from snf_django.management.commands import SynnefoCommand |
40 | 40 |
|
41 | 41 |
from astakos.oa2.models import Client, RedirectUrl |
42 |
from astakos.oa2 import settings |
|
42 | 43 |
|
43 | 44 |
|
44 | 45 |
class Command(SynnefoCommand): |
... | ... | |
74 | 75 |
if len(args) != 1: |
75 | 76 |
raise CommandError("Invalid number of arguments") |
76 | 77 |
|
77 |
if not options['urls']: |
|
78 |
urls = filter(lambda u: len(u) < |
|
79 |
settings.MAXIMUM_ALLOWED_REDIRECT_URI_LENGTH, |
|
80 |
options['urls']) |
|
81 |
|
|
82 |
if len(options['urls']) != len(urls): |
|
83 |
self.stdout.write('The following urls are over the allowed limit ' |
|
84 |
'and are going to be ignored: %s\n' % |
|
85 |
','.join(set(options['urls']) - set(urls))) |
|
86 |
|
|
87 |
if not urls: |
|
78 | 88 |
raise CommandError("There should be at least one redirect URI") |
79 | 89 |
|
80 | 90 |
identifier = args[0].decode('utf8') |
... | ... | |
84 | 94 |
type=options['type'], is_trusted=options['is_trusted']) |
85 | 95 |
c.save() |
86 | 96 |
c.redirecturl_set.bulk_create((RedirectUrl(client=c, url=url) for |
87 |
url in options['urls']))
|
|
97 |
url in urls))
|
|
88 | 98 |
c.save() |
89 | 99 |
|
90 | 100 |
except BaseException, e: |
Also available in: Unified diff