def test_home_default(self): request = zoom.request.build('http://localhost/test') zoom.system.request.app.url = '/' self.assertEqual(zoom.system.site.url, '') self.assertEqual(request.path, '/test') response = zoom.home().render(request) self.assertEqual(response.headers['Location'], '<dz:abs_site_url>') response = zoom.home('page1').render(request) self.assertEqual(response.headers['Location'], '<dz:abs_site_url>/page1')
def confirm_registration(token): registration = get_registrations().first(token=token) delete_registration(token) if registration: if registration.expiry < time.time(): # happens if the user waits too long to validate content = load('expired.md') fills = dict(register_link=zoom.helpers.url_for('/register')) result = zoom.page(content, fills) elif email_registered(registration.email): # can happen if someone registers using the same email address # between the time that we issue the token and when the user gets # around to confirming. result = zoom.page(load('already_registered.md')) elif not username_available(registration.username): # can happen if someone registers using the same username # between the time that we issue the token and when the user gets # around to confirming. result = zoom.page( load('name_taken.md', username=registration.username) ) else: # good to go register_user(registration) result = zoom.home('thank-you') if zoom.system.request.user.is_admin: msg = 'registration activated for {}'.format(registration.username) zoom.alerts.success(msg) return result
def app(request): """Return a page containing a list of available apps""" zoom.requires('fontawesome4') css = """ .app-icons ul { list-style-type: none; margin-top: 50px; } .app-icons li { display: inline; } .zoom-app-as-icon { width: 110px; height: 120px; text-align: center; float: left; } .zoom-app-as-icon:hover { background: #eee; } .zoom-app-icon { height: 50px; width: 50px; border-radius: 5px; margin-top: 16px; padding-top: 5px; line-height: 50px; text-align: center; box-shadow: inset 0px 49px 0px -24px #67828b; background-color: #5a7179; border: 1px solid #ffffff; display: inline-block; color: #ffffff; font-size: 15px; text-decoration: none; } .zoom-app-icon .fa { font-size: 2em; } """ if len(request.route) > 1 or request.data: return zoom.home() skip = 'home', 'logout', 'login', 'settings' content = h.div( h.ul( a.as_icon for a in sorted(request.site.apps, key=lambda a: a.title.lower()) if a.name not in skip and a.visible and request.user.can_run(a) ), classed='app-icons' ) + '<div style="clear:both"></div>' return zoom.page(content, css=css)
def save_button(self, *args, **kwargs): if args and args[0] == 'site': if self.site_form.validate(kwargs): model.save_site_settings(self.site_form.evaluate()) zoom.alerts.success('site settings saved') return zoom.home(args[0]) return None if args and args[0] == 'theme': if self.theme_form.validate(kwargs): model.save_theme_settings(self.theme_form.evaluate()) zoom.alerts.success('theme settings saved') return zoom.home(args[0]) return None if args and args[0] == 'mail': if self.mail_form.validate(kwargs): model.save_mail_settings(self.mail_form.evaluate()) zoom.alerts.success('mail settings saved') return zoom.home(args[0]) return None
def done_button(self, key, **data): return zoom.home('images')
def impersonate(self, username): zoom.impersonation.impersonate(username) zoom.alerts.success(f'Impersonating {username}!') return zoom.home()
def reset(self): zoom.system.site.settings.clear() return zoom.home('mail')
def index(self, selected=None, *args, **kwargs): """index page""" return zoom.home('site')
def confirm(self, token): """Registration confirmation""" result = model.confirm_registration(token) if zoom.system.request.user.is_admin: return zoom.home('list') return result
def clear(self): zoom.store_of(zoom.background.BackgroundJobPlaceholder).zap() return zoom.home('jobs')
def delete(self, token): delete_registration(token) return home()
def confirm(self, token): result = confirm_registration(token) if user.is_admin: return home() return result
def clear_queues(self): zoom.system.site.queues.clear() zoom.alerts.success('queues cleared') return zoom.home()
def cancel(self): return zoom.home()
def delete(self, token): model.delete_registration(token) return zoom.home()
def clear(self): """Clear the search""" return zoom.home()
def clear(self): """clear settings""" self.settings.clear() zoom.alerts.success('settings cleared') return zoom.home('settings')