diff --git a/action/user.py b/action/user.py index 4134f00..c3520ac 100644 --- a/action/user.py +++ b/action/user.py @@ -52,7 +52,7 @@ class UserCreate(UserBase): self.propagate_exception(e) request.connection.commit() - return request.answer.complete_redirect(['user', str(user.id)]) + return request.answer.complete_redirect(['user', str(user.login)]) class UserUpdate(UserBase): @@ -70,7 +70,7 @@ class UserUpdate(UserBase): self.propagate_exception(e) request.connection.commit() - return request.answer.complete_redirect(['user', str(user.id)]) + return request.answer.complete_redirect(['user', str(user.login)]) class UserDelete(UserBase): @@ -114,7 +114,7 @@ class UserSetPassword(UserBase): self.propagate_exception(e) request.connection.commit() - return request.answer.complete_redirect(['user', str(user.id)]) + return request.answer.complete_redirect(['user', str(user.login)]) class UserSetSuperuser(UserBase): @@ -132,7 +132,7 @@ class UserSetSuperuser(UserBase): self.propagate_exception(e) request.connection.commit() - return request.answer.complete_redirect(['user', str(user.id)]) + return request.answer.complete_redirect(['user', str(user.login)]) actions = { diff --git a/answer.py b/answer.py index 82789ac..e625a2d 100644 --- a/answer.py +++ b/answer.py @@ -35,7 +35,7 @@ class Answer(Translator): self.text = '' self.html = '' - self.title = '' + self.uipath = list() self.content = '' self.errors = list() self.fields = dict() @@ -58,12 +58,10 @@ class Answer(Translator): def encodedfield(self, name): return self.e( self.fields.get(str(name), '') ) - def chain_title(self, subtitle): - if subtitle: - if self.title: - self.title = subtitle + ' | ' + self.title - else: - self.title = subtitle + def add_uipath_entry(self, title, path): + assert(type(title) is str) + assert(type(path) is list) + self.uipath.append((title, path)) def complete_redirect(self, path = None): self.status = '303 See Other' diff --git a/config.py b/config.py index 926930d..8757960 100644 --- a/config.py +++ b/config.py @@ -1,6 +1,7 @@ config = { 'domain' : 'earthworm.local', + 'debug' : True, 'db': { 'prefix' : 'ew_', diff --git a/generator/form.py b/generator/form.py index bf07aab..7180418 100644 --- a/generator/form.py +++ b/generator/form.py @@ -44,7 +44,16 @@ class Form(): content = '' + return content + + def checkbox(self, name, value = None): + name = self.answer.e(name) + value = bool(self.answer.fields.get(name) if value is None else value) + content = '' return content @@ -89,6 +98,8 @@ class Form(): self.content += self.input(name, 'hidden', '' if value is None else value) def add_input(self, title, *args, **kvargs): self.add_field_raw(title, self.input(*args, **kvargs)) + def add_checkbox(self, title, *args, **kvargs): + self.add_field_raw(title, self.checkbox(*args, **kvargs)) def add_select(self, title, *args, **kvargs): self.add_field_raw(title, self.select(*args, **kvargs)) def add_textarea(self, title, *args, **kvargs): @@ -98,7 +109,7 @@ class Form(): def begin(self, title, action): self.content += self.BEGIN - self.content += self.title(title) + if title: self.content += self.title(title) if action: self.add_hidden('action', action) def end(self): self.content += self.END diff --git a/page/repo.py b/page/repo.py index b3dc1ee..36c809f 100644 --- a/page/repo.py +++ b/page/repo.py @@ -13,10 +13,10 @@ class RepoCreatePage(Page): if not request.model.repositories.can_create(user.id): raise exception.HttpNotFound() answer = request.answer - answer.chain_title( answer.te('Create repository') ) + answer.add_uipath_entry( answer.t('Create repository'), prevpath ) form = Form(request) - form.begin('Create repository', 'repo.create') + form.begin('', 'repo.create') form.add_hidden('user_id', user.id) form.add_select('type:', 'type', { k: v.name for k, v in request.server.repotypes.items() }) form.add_input('name:', 'name', 'text') @@ -38,17 +38,15 @@ class RepoPage(Page): if not path: raise exception.HttpNotFound() + answer = request.answer + user = request.answer.objects['user'] - repo = None - if path[0].isdecimal(): - repo = request.model.repositories.get_by_id(int(path[0]), user) - else: - repo = request.model.repositories.get_by_name(user.id, str(path[0]), user) + repo = request.model.repositories.get_by_name(user.id, str(path[0]), user) if not repo: raise exception.HttpNotFound() - request.answer.objects['repo'] = repo - request.answer.chain_title( request.answer.e(repo.title) ) + answer.objects['repo'] = repo + answer.add_uipath_entry( repo.title, prevpath + [repo.name] ) return self.view.sub_process(request, path, prevpath) @@ -62,7 +60,6 @@ class RepoViewPage(Page): repo = request.answer.objects['repo'] answer = request.answer - answer.chain_title( answer.e(repo.name) ) if path: if path[0] == 'edit': @@ -71,12 +68,15 @@ class RepoViewPage(Page): return self.delete.sub_process(request, path, prevpath) raise exception.HttpNotFound() - answer.content += '
' + answer.te(repo.repotype.name) + '
\n' answer.content += '' + answer.e(repo.name) + '
\n' - answer.content += '' + answer.e(repo.title) + '
\n' answer.content += '' + answer.e(repo.description) + '
\n' - answer.content += '' + request.protocol + request.domain + '/repo/' + repo.gen_subpath() + '
\n' + answer.content += '' + answer.te('clone url:') + ' ' \ + + request.protocol \ + + request.domain \ + + '/repo/' \ + + repo.gen_subpath() \ + + '
\n' if repo.can_update(): answer.content += '' + self.make_link(answer, prevpath + ['edit'], 'Edit repository') + '
\n' @@ -94,10 +94,10 @@ class RepoUpdatePage(Page): if not repo.can_update(): raise exception.HttpNotFound() - answer.chain_title( answer.te('Edit repository') ) + answer.add_uipath_entry( answer.t('Edit repository') ) form = Form(request) - form.begin('Edit repository', 'repo.update') + form.begin('Details', 'repo.update') form.add_hidden('repository_id', repo.id) form.add_input('title:', 'title', 'text', repo.title) form.add_textarea('description:', 'description', repo.description) @@ -128,8 +128,10 @@ class RepoDeletePage(Page): if not repo.can_delete(): raise exception.HttpNotFound() + answer.add_uipath_entry( answer.t('Delete repository'), prevpath ) + form = Form(request) - form.begin('Delete repository', 'repo.delete') + form.begin('', 'repo.delete') form.add_hidden('repository_id', repo.id) form.content += '' + answer.te(repo.repotype.name) + '
\n' form.content += '' + answer.e(repo.name) + '
\n' @@ -137,10 +139,11 @@ class RepoDeletePage(Page): form.content += '' + answer.e(repo.description) + '
\n' form.content += '' + answer.e(repo.description) + '
\n' form.content += '' + request.protocol + request.domain + '/repo/' + repo.gen_subpath() + '
\n' + form.content += '' + answer.te('Do you really want do delete repository?') + '
\n' form.add_submit('Confirm delete') form.end() - answer.content += form.content + return answer.complete_content() @@ -155,9 +158,8 @@ class RepoListPage(Page): repositories = request.model.repositories.get_list(user) answer = request.answer - answer.chain_title( answer.te('Repositories') ) + answer.add_uipath_entry( answer.t('Repositories'), prevpath ) - answer.content += '' \
diff --git a/page/root.py b/page/root.py
index 2f4d184..083ee4f 100644
--- a/page/root.py
+++ b/page/root.py
@@ -17,6 +17,8 @@ class RootPage(Page):
answer = request.answer
answer.template = self.commontemplate
+ answer.add_uipath_entry( answer.t(request.server.config['name']), prevpath )
+
if path:
if path[0] == 'user':
return self.user.sub_process(request, path, prevpath)
@@ -30,19 +32,20 @@ class RootPage(Page):
else:
raise exception.HttpNotFound()
- answer.content += ' ' + answer.te('root page') + ' ' + answer.te('Welcome!') + ' ' + self.make_link(answer, prevpath + ['users'], 'Users list') + ' Env: \n' + answer.e(str(request.env)) + ' Env: \n' + answer.e(str(request.env)) + ' DB tables: ' + answer.e(', '.join(tables)) + ' DB tables: ' + answer.e(', '.join(tables)) + ' Rows of test table: ' + answer.e(str(rows)) + ' Rows of test table: ' + answer.e(str(rows)) + ' ' + answer.te('Create user') + ' ' + answer.e(user.login) + ' ' + answer.e(user.name) + ' ' + answer.te('Site admin') + ' ' + self.make_link(answer, prevpath + ['edit'], 'Edit user') + ' ' + self.make_link(answer, prevpath + ['repos'], 'Repositories') + ' ' + answer.te('Edit user') + ' ' + answer.e(user.login) + ' ' + answer.te('Change password') + ' ' + answer.te('Global rights') + ' ' + answer.te('Deletion') + ' ' + answer.te('Users list') + ' ' \
- + answer.e(user.id) + ' ' \
+ answer.e(user.login) + ' ' \
+ answer.e(user.name) + '' + answer.te('Welcome!') + '
'
if request.model.users.can_list():
answer.content += '' + answer.te('Debug data:') + '
'
+ answer.content += '' + answer.te('User profile') + '
\n'
answer.content += '