Revision 76a13815 snf-webproject/synnefo/webproject/management/commands/__init__.py
b/snf-webproject/synnefo/webproject/management/commands/__init__.py | ||
---|---|---|
37 | 37 |
from django.core.exceptions import FieldError |
38 | 38 |
|
39 | 39 |
from synnefo.webproject.management import util |
40 |
from synnefo.management.common import UserCache
|
|
40 |
from synnefo.lib.astakos import UserCache
|
|
41 | 41 |
|
42 | 42 |
|
43 | 43 |
class ListCommand(BaseCommand): |
... | ... | |
92 | 92 |
filters = {} |
93 | 93 |
excludes = {} |
94 | 94 |
|
95 |
# Fields used only with user_user_field |
|
96 |
astakos_url = None |
|
97 |
astakos_token = None |
|
98 |
|
|
95 | 99 |
help = "Generic List Command" |
96 | 100 |
option_list = BaseCommand.option_list + ( |
97 | 101 |
make_option( |
... | ... | |
135 | 139 |
|
136 | 140 |
def __init__(self, *args, **kwargs): |
137 | 141 |
if self.user_uuid_field: |
142 |
assert(self.astakos_url), "astakos_url attribute is needed when"\ |
|
143 |
" user_uuid_field is declared" |
|
144 |
assert(self.astakos_token), "astakos_token attribute is needed"\ |
|
145 |
" user_uuid_field is declared" |
|
138 | 146 |
self.option_list += ( |
139 | 147 |
make_option( |
140 | 148 |
"-u", "--user", |
... | ... | |
195 | 203 |
user = options.get("user") |
196 | 204 |
if user: |
197 | 205 |
if "@" in user: |
198 |
user = UserCache().get_uuid(user) |
|
206 |
ucache = UserCache(self.astakos_url, self.astakos_token) |
|
207 |
user = ucache.get_uuid(user) |
|
199 | 208 |
self.filters[self.user_uuid_field] = user |
200 | 209 |
|
201 | 210 |
# --deleted option |
... | ... | |
228 | 237 |
self.FIELDS["user.email"] =\ |
229 | 238 |
("user_email", "The email of the owner.") |
230 | 239 |
uuids = [getattr(obj, self.user_uuid_field) for obj in objects] |
231 |
ucache = UserCache() |
|
240 |
ucache = UserCache(self.astakos_url, self.astakos_token)
|
|
232 | 241 |
ucache.fetch_names(list(set(uuids))) |
233 | 242 |
for obj in objects: |
234 | 243 |
uuid = getattr(obj, self.user_uuid_field) |
Also available in: Unified diff