Пример #1
0
    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')
Пример #2
0
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
Пример #3
0
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)
Пример #4
0
    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
Пример #5
0
 def done_button(self, key, **data):
     return zoom.home('images')
Пример #6
0
 def impersonate(self, username):
     zoom.impersonation.impersonate(username)
     zoom.alerts.success(f'Impersonating {username}!')
     return zoom.home()
Пример #7
0
 def reset(self):
     zoom.system.site.settings.clear()
     return zoom.home('mail')
Пример #8
0
 def index(self, selected=None, *args, **kwargs):
     """index page"""
     return zoom.home('site')
Пример #9
0
 def confirm(self, token):
     """Registration confirmation"""
     result = model.confirm_registration(token)
     if zoom.system.request.user.is_admin:
         return zoom.home('list')
     return result
Пример #10
0
 def clear(self):
     zoom.store_of(zoom.background.BackgroundJobPlaceholder).zap()
     return zoom.home('jobs')
Пример #11
0
 def delete(self, token):
     delete_registration(token)
     return home()
Пример #12
0
 def confirm(self, token):
     result = confirm_registration(token)
     if user.is_admin:
         return home()
     return result
Пример #13
0
 def clear_queues(self):
     zoom.system.site.queues.clear()
     zoom.alerts.success('queues cleared')
     return zoom.home()
Пример #14
0
 def cancel(self):
     return zoom.home()
Пример #15
0
 def delete(self, token):
     model.delete_registration(token)
     return zoom.home()
Пример #16
0
 def clear(self):
     """Clear the search"""
     return zoom.home()
Пример #17
0
 def clear(self):
     """clear settings"""
     self.settings.clear()
     zoom.alerts.success('settings cleared')
     return zoom.home('settings')