Beispiel #1
0
    def __call__(self, request):
        request.need_setup = False
        request.need_upgrade = False
        request.kbsite = None

        installed_version = models.KegbotSite.get_installed_version()
        if installed_version is None:
            request.need_setup = True
        else:
            request.installed_version_string = str(installed_version)
            request.need_upgrade = must_upgrade(installed_version,
                                                get_version_object())

        if not request.need_setup and not request.need_upgrade:
            request.kbsite = models.KegbotSite.objects.get(name='default')
            if request.kbsite.is_setup:
                timezone.activate(request.kbsite.timezone)
                request.plugins = dict(
                    (p.get_short_name(), p)
                    for p in list(plugin_util.get_plugins().values()))
            else:
                request.need_setup = True
            request.backend = get_kegbot_backend()

        return self.get_response(request)
Beispiel #2
0
    def process_request(self, request):
        epoch = None
        request.need_setup = False
        request.need_upgrade = False
        request.kbsite = None

        # Select only the `epoch` column, as pending database migrations could
        # make a full select crash.
        rows = models.KegbotSite.objects.filter(name='default').values('epoch')
        if not rows:
            request.need_setup = True
        elif rows[0].get('epoch', 0) < EPOCH:
            request.need_upgrade = True
        else:
            request.kbsite = models.KegbotSite.objects.get(name='default')
            if request.kbsite.is_setup:
                timezone.activate(request.kbsite.timezone)
                request.plugins = dict((p.get_short_name(), p) for p in plugin_util.get_plugins())
            else:
                request.need_setup = True

        request.kbcache = KegbotCache()
        request.backend = get_kegbot_backend()

        return None
Beispiel #3
0
    def process_request(self, request):
        request.need_setup = False
        request.need_upgrade = False
        request.kbsite = None

        # Select only the `epoch` column, as pending database migrations could
        # make a full select crash.
        rows = models.KegbotSite.objects.filter(name='default').values('epoch')
        if not rows:
            request.need_setup = True
        elif rows[0].get('epoch', 0) < EPOCH:
            request.need_upgrade = True
        else:
            request.kbsite = models.KegbotSite.objects.get(name='default')
            if request.kbsite.is_setup:
                timezone.activate(request.kbsite.timezone)
                request.plugins = dict(
                    (p.get_short_name(), p)
                    for p in plugin_util.get_plugins().values())
            else:
                request.need_setup = True

        request.backend = get_kegbot_backend()

        return None
Beispiel #4
0
def schedule_tasks(events):
    """Synchronously schedules tasks related to the given events."""
    for plugin in plugin_util.get_plugins().values():
        try:
            plugin.handle_new_events(events)
        except Exception:
            logger.exception('Error dispatching events to plugin {}'.format(plugin.get_name()))
    notification.handle_new_system_events(events)
Beispiel #5
0
def schedule_tasks(events):
    """Synchronously schedules tasks related to the given events."""
    for plugin in plugin_util.get_plugins().values():
        try:
            plugin.handle_new_events(events)
        except Exception:
            logger.exception('Error dispatching events to plugin {}'.format(plugin.get_name()))
    notification.handle_new_system_events(events)
Beispiel #6
0
    def __call__(self, request):
        if request.kbsite and not request.need_setup:
            timezone.activate(request.kbsite.timezone)
            request.plugins = dict(
                (p.get_short_name(), p)
                for p in list(plugin_util.get_plugins().values()))
            request.backend = get_kegbot_backend()

        return self.get_response(request)
Beispiel #7
0
def schedule_tasks(event_list):
    """Synchronously schedules tasks related to the given events, if any."""
    web_hook_urls = models.SiteSettings.get().web_hook_urls
    if web_hook_urls:
        urls = [u for u in web_hook_urls.split() if u]
        for url in urls:
            post_webhook_event.delay(url, event_list)

    for event in event_list:
        for plugin in plugin_util.get_plugins():
            plugin.handle_new_event(event)
Beispiel #8
0
def schedule_tasks(event_list):
    """Synchronously schedules tasks related to the given events, if any."""
    web_hook_urls = models.SiteSettings.get().web_hook_urls
    if web_hook_urls:
        urls = [u for u in web_hook_urls.split() if u]
        for url in urls:
            post_webhook_event.delay(url, event_list)

    for event in event_list:
        for plugin in plugin_util.get_plugins():
            plugin.handle_new_event(event)
    def process_request(self, request):
        request.need_setup = False
        request.need_upgrade = False
        request.kbsite = None

        installed_version = models.KegbotSite.get_installed_version()
        if installed_version is None:
            request.need_setup = True
        else:
            request.installed_version_string = str(installed_version)
            request.need_upgrade = must_upgrade(installed_version, get_version_object())

        if not request.need_setup and not request.need_upgrade:
            request.kbsite = models.KegbotSite.objects.get(name='default')
            if request.kbsite.is_setup:
                timezone.activate(request.kbsite.timezone)
                request.plugins = dict((p.get_short_name(), p) for p in plugin_util.get_plugins().values())
            else:
                request.need_setup = True

        request.backend = get_kegbot_backend()

        return None
Beispiel #10
0
        r"^controllers/(?P<controller_id>\d+)/$",
        views.controller_detail,
        name="kegadmin-edit-controller",
    ),
    url(r"^taps/$", views.tap_list, name="kegadmin-taps"),
    url(r"^taps/create/$", views.add_tap, name="kegadmin-add-tap"),
    url(r"^taps/(?P<tap_id>\d+)/$", views.tap_detail, name="kegadmin-edit-tap"),
    url(r"^users/$", views.user_list, name="kegadmin-users"),
    url(r"^users/(?P<user_id>\d+)/$", views.user_detail, name="kegadmin-edit-user"),
    url(r"^drinks/$", views.drink_list, name="kegadmin-drinks"),
    url(r"^drinks/(?P<drink_id>\d+)/$", views.drink_edit, name="kegadmin-edit-drink"),
    url(r"^tokens/$", views.token_list, name="kegadmin-tokens"),
    url(r"^tokens/create/$", views.add_token, name="kegadmin-add-token"),
    url(r"^tokens/(?P<token_id>\d+)/$", views.token_detail, name="kegadmin-edit-token"),
    url(
        r"^autocomplete/beverage/$",
        views.autocomplete_beverage,
        name="kegadmin-autocomplete-beverage",
    ),
    url(r"^autocomplete/user/$", views.autocomplete_user, name="kegadmin-autocomplete-user"),
    url(r"^autocomplete/token/$", views.autocomplete_token, name="kegadmin-autocomplete-token"),
    url(r"^plugin/(?P<plugin_name>\w+)/$", views.plugin_settings, name="kegadmin-plugin-settings"),
    url(r"^email/$", views.email, name="kegadmin-email"),
    url(r"^logs/$", views.logs, name="kegadmin-logs"),
    url(r"^users/create/$", views.add_user, name="kegadmin-add-user"),
    url(r"^workers/$", views.workers, name="kegadmin-workers"),
]

if util.get_plugins():
    urlpatterns += util.get_admin_urls()
Beispiel #11
0
    url(r'^taps/$', 'tap_list', name='kegadmin-taps'),
    url(r'^taps/create/$', 'add_tap', name='kegadmin-add-tap'),
    url(r'^taps/(?P<tap_id>\d+)/$', 'tap_detail', name='kegadmin-edit-tap'),

    url(r'^users/$', 'user_list', name='kegadmin-users'),
    url(r'^users/create/$', 'add_user', name='kegadmin-add-user'),
    url(r'^users/(?P<user_id>\d+)/$', 'user_detail', name='kegadmin-edit-user'),

    url(r'^drinks/$', 'drink_list', name='kegadmin-drinks'),
    url(r'^drinks/(?P<drink_id>\d+)/$', 'drink_edit', name='kegadmin-edit-drink'),

    url(r'^tokens/$', 'token_list', name='kegadmin-tokens'),
    url(r'^tokens/create/$', 'add_token', name='kegadmin-add-token'),
    url(r'^tokens/(?P<token_id>\d+)/$', 'token_detail', name='kegadmin-edit-token'),

    url(r'^logs/$', 'logs', name='kegadmin-logs'),
    url(r'^autocomplete/beverage/$', 'autocomplete_beverage',
      name='kegadmin-autocomplete-beverage'),
    url(r'^autocomplete/user/$', 'autocomplete_user',
      name='kegadmin-autocomplete-user'),
    url(r'^autocomplete/token/$', 'autocomplete_token',
      name='kegadmin-autocomplete-token'),

    url(r'^plugin/(?P<plugin_name>\w+)/$', 'plugin_settings', name='kegadmin-plugin-settings'),
)

from pykeg.plugin import util
if util.get_plugins():
    urlpatterns += util.get_admin_urls()
Beispiel #12
0
def schedule_tasks(events):
    """Synchronously schedules tasks related to the given events."""
    for event in events:
        for plugin in plugin_util.get_plugins():
            plugin.handle_new_event(event)
    notification.handle_new_system_events(events)
Beispiel #13
0
def schedule_tasks(event_list):
    """Synchronously schedules tasks related to the given events."""
    for event in event_list:
        for plugin in plugin_util.get_plugins():
            plugin.handle_new_event(event)
Beispiel #14
0
def schedule_tasks(events):
    """Synchronously schedules tasks related to the given events."""
    for plugin in plugin_util.get_plugins():
        plugin.handle_new_events(events)
    notification.handle_new_system_events(events)