@@ 74-109 (lines=36) @@ | ||
71 | csrf_protect_m = method_decorator(csrf_protect) |
|
72 | ||
73 | ||
74 | def get_supplement_admin_inline_base_class(path=None): |
|
75 | """ |
|
76 | Return a class of a admin inline class for registration supplement, |
|
77 | given the dotted Python import path (as a string) to the admin inline |
|
78 | class. |
|
79 | ||
80 | If the addition cannot be located (e.g., because no such module |
|
81 | exists, or because the module does not contain a class of the |
|
82 | appropriate name), ``django.core.exceptions.ImproperlyConfigured`` |
|
83 | is raised. |
|
84 | ||
85 | """ |
|
86 | path = path or settings.REGISTRATION_SUPPLEMENT_ADMIN_INLINE_BASE_CLASS |
|
87 | i = path.rfind('.') |
|
88 | module, attr = path[:i], path[i+1:] |
|
89 | try: |
|
90 | mod = import_module(module) |
|
91 | except ImportError as e: |
|
92 | raise ImproperlyConfigured(( |
|
93 | 'Error loading admin inline class for registration supplement ' |
|
94 | '%s: "%s"' |
|
95 | ) % (module, e)) |
|
96 | try: |
|
97 | cls = getattr(mod, attr) |
|
98 | except AttributeError: |
|
99 | raise ImproperlyConfigured(( |
|
100 | 'Module "%s" does not define a admin inline class for ' |
|
101 | 'registration supplement named "%s"' |
|
102 | ) % (module, attr)) |
|
103 | if cls and not issubclass(cls, RegistrationSupplementAdminInlineBase): |
|
104 | raise ImproperlyConfigured(( |
|
105 | 'Admin inline class for registration supplement class "%s" ' |
|
106 | 'must be a subclass of ``registration.admin.' |
|
107 | 'RegistrationSupplementAdminInlineBase``' |
|
108 | ) % path) |
|
109 | return cls |
|
110 | ||
111 | ||
112 | class RegistrationSupplementAdminInlineBase(admin.StackedInline): |
@@ 52-81 (lines=30) @@ | ||
49 | from registration.backends.base import RegistrationBackendBase |
|
50 | ||
51 | ||
52 | def get_backend_class(path=None): |
|
53 | """ |
|
54 | Return an class of a registration backend, given the dotted |
|
55 | Python import path (as a string) to the backend class. |
|
56 | ||
57 | If the backend cannot be located (e.g., because no such module |
|
58 | exists, or because the module does not contain a class of the |
|
59 | appropriate name), ``django.core.exceptions.ImproperlyConfigured`` |
|
60 | is raised. |
|
61 | ||
62 | """ |
|
63 | path = path or settings.REGISTRATION_BACKEND_CLASS |
|
64 | i = path.rfind('.') |
|
65 | module, attr = path[:i], path[i+1:] |
|
66 | try: |
|
67 | mod = import_module(module) |
|
68 | except ImportError as e: |
|
69 | raise ImproperlyConfigured( |
|
70 | 'Error loading registration backend %s: "%s"' % (module, e)) |
|
71 | try: |
|
72 | cls = getattr(mod, attr) |
|
73 | except AttributeError: |
|
74 | raise ImproperlyConfigured(( |
|
75 | 'Module "%s" does not define a registration backend named "%s"' |
|
76 | ) % (module, attr)) |
|
77 | if cls and not issubclass(cls, RegistrationBackendBase): |
|
78 | raise ImproperlyConfigured(( |
|
79 | 'Registration backend class "%s" must be a subclass of ' |
|
80 | '``registration.backends.RegistrationBackendBase``') % path) |
|
81 | return cls |
|
82 | ||
83 | ||
84 | def get_backend(path=None): |