Commit c48719877d70ae33bbefb0a1ea8add5f3dde2918
1 parent
b6286ca2
Exists in
master
Definição de um valor default caso a variável PROFILES não esteja configurada.
Showing
2 changed files
with
12 additions
and
1 deletions
Show diff stats
pybossa/repositories/user_repository.py
... | ... | @@ -96,6 +96,14 @@ class UserRepository(object): |
96 | 96 | |
97 | 97 | def get_profile_by(self, **attributes): |
98 | 98 | return self.db.session.query(Profile).filter_by(**attributes).first() |
99 | + | |
100 | + def get_profiles_list(self): | |
101 | + profiles = self.db.session.query(Profile).all() | |
102 | + result = [] | |
103 | + for profile in profiles: | |
104 | + name = profile.name | |
105 | + result.append((name, name)) | |
106 | + return result | |
99 | 107 | |
100 | 108 | def profile_has_access(self, user, project_name): |
101 | 109 | profile = self.get_profile(user.profile_id) | ... | ... |
pybossa/view/account.py
... | ... | @@ -199,7 +199,10 @@ def register(): |
199 | 199 | |
200 | 200 | """ |
201 | 201 | form = RegisterForm(request.form) |
202 | - form.set_profile_choices(current_app.config.get('PROFILES')) | |
202 | + profiles = current_app.config.get('PROFILES') | |
203 | + if profiles is None: | |
204 | + profiles = user_repo.get_profiles_list() | |
205 | + form.set_profile_choices(profiles) | |
203 | 206 | if request.method == 'POST' and form.validate(): |
204 | 207 | account = dict(fullname=form.fullname.data, name=form.name.data, |
205 | 208 | email_addr=form.email_addr.data, | ... | ... |