def configure_project_plugin(request, project, slug): try: plugin = request.plugins[slug] except KeyError: return HttpResponseRedirect( reverse('sentry-manage-project', args=[project.pk])) form = plugin.project_conf_form if form is None: return HttpResponseRedirect( reverse('sentry-manage-project', args=[project.pk])) action, view = plugin_config(plugin, project, request) if action == 'redirect': return HttpResponseRedirect(request.path + '?success=1') context = csrf(request) context.update({ 'page': 'plugin', 'title': plugin.get_title(), 'view': view, 'project': project, 'plugin': plugin, }) return render_to_response('sentry/projects/plugins/configure.html', context, request)
def configure_project_plugin(request, project, slug): try: plugin = plugins.get(slug) except KeyError: return HttpResponseRedirect(reverse("sentry-manage-project", args=[project.slug])) if not plugin.is_enabled(project): return HttpResponseRedirect(reverse("sentry-manage-project", args=[project.slug])) result = plugins.first("has_perm", request.user, "configure_project_plugin", project, plugin) if result is False and not request.user.is_superuser: return HttpResponseRedirect(reverse("sentry")) form = plugin.project_conf_form if form is None: return HttpResponseRedirect(reverse("sentry-manage-project", args=[project.slug])) action, view = plugin_config(plugin, project, request) if action == "redirect": return HttpResponseRedirect(request.path + "?success=1") context = csrf(request) context.update({"page": "plugin", "title": plugin.get_title(), "view": view, "project": project, "plugin": plugin}) return render_to_response("sentry/projects/plugins/configure.html", context, request)
def configure_project_plugin(request, organization, project, slug): try: plugin = plugins.get(slug) except KeyError: return HttpResponseRedirect(reverse('sentry-manage-project', args=[project.organization.slug, project.slug])) if not plugin.can_enable_for_projects(): return HttpResponseRedirect(reverse('sentry-manage-project', args=[project.organization.slug, project.slug])) form = plugin.project_conf_form if form is None: return HttpResponseRedirect(reverse('sentry-manage-project', args=[project.organization.slug, project.slug])) action, view = plugin_config(plugin, project, request) if action == 'redirect': messages.add_message( request, messages.SUCCESS, _('Your settings were saved successfully.')) return HttpResponseRedirect(request.path) context = csrf(request) context.update({ 'organization': organization, 'team': project.team, 'page': 'plugin', 'title': plugin.get_title(), 'view': view, 'project': project, 'plugin': plugin, 'plugin_is_enabled': plugin.is_enabled(project), }) return render_to_response('sentry/projects/plugins/configure.html', context, request)
def configure_project_plugin(request, project, slug): try: plugin = plugins.get(slug) except KeyError: return HttpResponseRedirect(reverse('sentry-manage-project', args=[project.slug])) if not plugin.is_enabled(project): return HttpResponseRedirect(reverse('sentry-manage-project', args=[project.slug])) result = plugins.first('has_perm', request.user, 'configure_project_plugin', project, plugin) if result is False and not request.user.is_superuser: return HttpResponseRedirect(reverse('sentry')) form = plugin.project_conf_form if form is None: return HttpResponseRedirect(reverse('sentry-manage-project', args=[project.slug])) action, view = plugin_config(plugin, project, request) if action == 'redirect': return HttpResponseRedirect(request.path + '?success=1') context = csrf(request) context.update({ 'page': 'plugin', 'title': plugin.get_title(), 'view': view, 'project': project, 'plugin': plugin, }) return render_to_response('sentry/projects/plugins/configure.html', context, request)
def configure_plugin(request, slug): plugin = plugins.get(slug) if not plugin.has_site_conf(): return HttpResponseRedirect(reverse("sentry")) action, view = plugin_config(plugin, None, request) if action == "redirect": return HttpResponseRedirect(request.path) return render_to_response( "sentry/admin/plugins/configure.html", {"plugin": plugin, "title": plugin.get_conf_title(), "slug": plugin.slug, "view": view}, request, )
def configure_plugin(request, slug): plugin = plugins.get(slug) if not plugin.has_site_conf(): return HttpResponseRedirect(reverse('sentry')) action, view = plugin_config(plugin, None, request) if action == 'redirect': return HttpResponseRedirect(request.path) return render_to_response('sentry/admin/plugins/configure.html', { 'plugin': plugin, 'title': plugin.get_conf_title(), 'slug': plugin.slug, 'view': view, }, request)
def configure_project_plugin(request, team, project, slug): try: plugin = plugins.get(slug) except KeyError: return HttpResponseRedirect( reverse('sentry-manage-project', args=[project.team.slug, project.slug])) if not plugin.can_enable_for_projects(): return HttpResponseRedirect( reverse('sentry-manage-project', args=[project.team.slug, project.slug])) result = plugins.first('has_perm', request.user, 'configure_project_plugin', project, plugin) if result is False and not request.user.is_superuser: return HttpResponseRedirect(reverse('sentry')) form = plugin.project_conf_form if form is None: return HttpResponseRedirect( reverse('sentry-manage-project', args=[project.team.slug, project.slug])) action, view = plugin_config(plugin, project, request) if action == 'redirect': messages.add_message(request, messages.SUCCESS, _('Your settings were saved successfully.')) return HttpResponseRedirect(request.path) context = csrf(request) context.update({ 'team': team, 'page': 'plugin', 'title': plugin.get_title(), 'view': view, 'project': project, 'plugin': plugin, 'plugin_is_enabled': plugin.is_enabled(project), 'SECTION': 'team', 'SUBSECTION': 'projects' }) return render_to_response('sentry/projects/plugins/configure.html', context, request)
def configure_project_plugin(request, organization, project, slug): try: plugin = plugins.get(slug) except KeyError: return HttpResponseRedirect( reverse('sentry-manage-project', args=[project.organization.slug, project.slug])) if not plugin.can_enable_for_projects(): return HttpResponseRedirect( reverse('sentry-manage-project', args=[project.organization.slug, project.slug])) form = plugin.project_conf_form if form is None: return HttpResponseRedirect( reverse('sentry-manage-project', args=[project.organization.slug, project.slug])) action, view = plugin_config(plugin, project, request) if action == 'redirect': messages.add_message(request, messages.SUCCESS, _('Your settings were saved successfully.')) return HttpResponseRedirect(request.path) context = csrf(request) context.update({ 'organization': organization, 'team': project.team, 'page': 'plugin', 'title': plugin.get_title(), 'view': view, 'project': project, 'plugin': plugin, 'plugin_is_enabled': plugin.is_enabled(project), }) return render_to_response('sentry/projects/plugins/configure.html', context, request)
def handle(self, request, organization, team, project): if request.method == 'POST': op = request.POST.get('op') if op == 'enable': self._handle_enable_plugin(request, project) return HttpResponseRedirect(request.path) elif op == 'disable': self._handle_disable_plugin(request, project) return HttpResponseRedirect(request.path) enabled_plugins = [] other_plugins = [] for plugin in self._iter_plugins(): if plugin.is_enabled(project): content = plugin.get_issue_doc_html() form = plugin.project_conf_form if form is not None: action, view = plugin_config(plugin, project, request) if action == 'redirect': messages.add_message( request, messages.SUCCESS, constants.OK_PLUGIN_SAVED.format( name=plugin.get_title()), ) return HttpResponseRedirect(request.path) elif content: enabled_plugins.append((plugin, mark_safe(content))) enabled_plugins.append((plugin, mark_safe(content + view))) else: other_plugins.append(plugin) context = { 'page': 'issue-tracking', 'enabled_plugins': enabled_plugins, 'other_plugins': other_plugins, } return self.respond('sentry/project-issue-tracking.html', context)
def configure_project_plugin(request, team, project, slug): try: plugin = plugins.get(slug) except KeyError: return HttpResponseRedirect(reverse('sentry-manage-project', args=[project.team.slug, project.slug])) if not plugin.can_enable_for_projects(): return HttpResponseRedirect(reverse('sentry-manage-project', args=[project.team.slug, project.slug])) result = plugins.first('has_perm', request.user, 'configure_project_plugin', project, plugin) if result is False and not request.user.is_superuser: return HttpResponseRedirect(reverse('sentry')) form = plugin.project_conf_form if form is None: return HttpResponseRedirect(reverse('sentry-manage-project', args=[project.team.slug, project.slug])) action, view = plugin_config(plugin, project, request) if action == 'redirect': messages.add_message( request, messages.SUCCESS, _('Your settings were saved successfully.')) return HttpResponseRedirect(request.path) context = csrf(request) context.update({ 'team': team, 'page': 'plugin', 'title': plugin.get_title(), 'view': view, 'project': project, 'plugin': plugin, 'plugin_is_enabled': plugin.is_enabled(project), 'SECTION': 'team', 'SUBSECTION': 'projects' }) return render_to_response('sentry/projects/plugins/configure.html', context, request)
def configure_project_plugin(request, team, project, slug): try: plugin = plugins.get(slug) except KeyError: return HttpResponseRedirect(reverse("sentry-manage-project", args=[project.team.slug, project.slug])) if not plugin.can_enable_for_projects(): return HttpResponseRedirect(reverse("sentry-manage-project", args=[project.team.slug, project.slug])) result = plugins.first("has_perm", request.user, "configure_project_plugin", project, plugin) if result is False and not request.user.is_superuser: return HttpResponseRedirect(reverse("sentry")) form = plugin.project_conf_form if form is None: return HttpResponseRedirect(reverse("sentry-manage-project", args=[project.team.slug, project.slug])) action, view = plugin_config(plugin, project, request) if action == "redirect": messages.add_message(request, messages.SUCCESS, _("Your settings were saved successfully.")) return HttpResponseRedirect(request.path) context = csrf(request) context.update( { "team": team, "page": "plugin", "title": plugin.get_title(), "view": view, "project": project, "plugin": plugin, "plugin_is_enabled": plugin.is_enabled(project), "SECTION": "team", "SUBSECTION": "projects", } ) return render_to_response("sentry/projects/plugins/configure.html", context, request)
def handle(self, request, organization, team, project): if request.method == 'POST': op = request.POST.get('op') if op == 'enable': self._handle_enable_plugin(request, project) return HttpResponseRedirect(request.path) elif op == 'disable': self._handle_disable_plugin(request, project) return HttpResponseRedirect(request.path) enabled_plugins = [] other_plugins = [] for plugin in self._iter_plugins(): if plugin.is_enabled(project): content = plugin.get_issue_doc_html() form = plugin.project_conf_form if form is not None: action, view = plugin_config(plugin, project, request) if action == 'redirect': messages.add_message( request, messages.SUCCESS, constants.OK_PLUGIN_SAVED.format(name=plugin.get_title()), ) return HttpResponseRedirect(request.path) elif content: enabled_plugins.append((plugin, mark_safe(content))) enabled_plugins.append((plugin, mark_safe(content + view))) else: other_plugins.append(plugin) context = { 'page': 'issue-tracking', 'enabled_plugins': enabled_plugins, 'other_plugins': other_plugins, } return self.respond('sentry/project-issue-tracking.html', context)
def configure_project_plugin(request, project, slug): try: plugin = plugins.get(slug) except KeyError: return HttpResponseRedirect(reverse('sentry-manage-project', args=[project.pk])) form = plugin.project_conf_form if form is None: return HttpResponseRedirect(reverse('sentry-manage-project', args=[project.pk])) action, view = plugin_config(plugin, project, request) if action == 'redirect': return HttpResponseRedirect(request.path + '?success=1') context = csrf(request) context.update({ 'page': 'plugin', 'title': plugin.get_title(), 'view': view, 'project': project, 'plugin': plugin, }) return render_to_response('sentry/projects/plugins/configure.html', context, request)
def status(request): from sentry.views import View from sentry.processors import Processor if not request.user.is_staff: return HttpResponseRedirect(reverse('sentry')) # Deal with the plugins site_configs = [] for slug, title in request.plugins.for_site(): plugin = request.plugins[slug] action, view = plugin_config(plugin, None, request) if action == 'redirect': return HttpResponseRedirect(request.path) item = { 'plugin': plugin, 'title': plugin.get_title(), 'slug': plugin.slug, 'site_conf_title': plugin.get_conf_title(), 'view': view, } site_configs.append(item) config = [] for k in sorted(dir(settings)): if k == 'KEY': continue if k.startswith('_'): continue if k.upper() != k: continue config.append((k, getattr(settings, k))) worker_status = ( settings.QUEUE['transport'] == 'djkombu.transport.DatabaseTransport') if worker_status: pending_tasks = list( Queue.objects.filter(messages__visible=True, ).annotate( num=Sum('messages__id')).values_list('name', 'num')) # fetch queues which had no pending tasks pending_tasks.extend((q, 0) for q in Queue.objects.exclude(name__in=[ p[0] for p in pending_tasks ], ).values_list('name', flat=True)) else: pending_tasks = None return render_to_response( 'sentry/status.html', { 'config': config, 'environment': environment, 'python_version': sys.version, 'modules': sorted([(p.project_name, p.version) for p in pkg_resources.working_set]), 'extensions': [(cls.title, cls.__module__.rsplit('.', 1)[0]) for cls in Plugin.plugins.itervalues()], 'views': [(x.__class__.__name__, x.__module__) for x in View.handlers.all()], 'processors': [(x.__class__.__name__, x.__module__) for x in Processor.handlers.all()], 'pending_tasks': pending_tasks, 'worker_status': worker_status, 'site_configs': site_configs, }, request)
def handle(self, request, organization, team, project): op = request.POST.get('op') if op == 'enable': self._handle_enable_plugin(request, project) return HttpResponseRedirect(request.path) elif op == 'disable': self._handle_disable_plugin(request, project) return HttpResponseRedirect(request.path) if op == 'save-settings': general_form = NotificationSettingsForm( data=request.POST, prefix='general', initial={ 'subject_prefix': project.get_option( 'mail:subject_prefix', settings.EMAIL_SUBJECT_PREFIX), }, ) if general_form.is_valid(): project.update_option( 'mail:subject_prefix', general_form.cleaned_data['subject_prefix']) messages.add_message( request, messages.SUCCESS, OK_SETTINGS_SAVED) return HttpResponseRedirect(request.path) else: general_form = NotificationSettingsForm( prefix='general', initial={ 'subject_prefix': project.get_option( 'mail:subject_prefix', settings.EMAIL_SUBJECT_PREFIX), }, ) enabled_plugins = [] other_plugins = [] for plugin in self._iter_plugins(): if plugin.is_enabled(project): content = plugin.get_notification_doc_html() form = plugin.project_conf_form if form is not None: action, view = plugin_config(plugin, project, request) if action == 'redirect': messages.add_message( request, messages.SUCCESS, constants.OK_PLUGIN_SAVED.format(name=plugin.get_title()), ) return HttpResponseRedirect(request.path) enabled_plugins.append((plugin, mark_safe(content + view))) elif content: enabled_plugins.append((plugin, mark_safe(content))) else: other_plugins.append(plugin) context = { 'page': 'notifications', 'enabled_plugins': enabled_plugins, 'other_plugins': other_plugins, 'general_form': general_form, } return self.respond('sentry/project-notifications.html', context)
def handle(self, request, organization, team, project): op = request.POST.get('op') if op == 'enable': self._handle_enable_plugin(request, project) return HttpResponseRedirect(request.path) elif op == 'disable': self._handle_disable_plugin(request, project) return HttpResponseRedirect(request.path) if op == 'save-settings': general_form = NotificationSettingsForm( data=request.POST, prefix='general', initial={ 'subject_prefix': project.get_option('mail:subject_prefix', settings.EMAIL_SUBJECT_PREFIX), }, ) if general_form.is_valid(): project.update_option( 'mail:subject_prefix', general_form.cleaned_data['subject_prefix']) messages.add_message(request, messages.SUCCESS, OK_SETTINGS_SAVED) return HttpResponseRedirect(request.path) else: general_form = NotificationSettingsForm( prefix='general', initial={ 'subject_prefix': project.get_option('mail:subject_prefix', settings.EMAIL_SUBJECT_PREFIX), }, ) enabled_plugins = [] other_plugins = [] for plugin in self._iter_plugins(): if plugin.is_enabled(project): content = plugin.get_notification_doc_html() form = plugin.project_conf_form if form is not None: action, view = plugin_config(plugin, project, request) if action == 'redirect': messages.add_message( request, messages.SUCCESS, constants.OK_PLUGIN_SAVED.format( name=plugin.get_title()), ) return HttpResponseRedirect(request.path) enabled_plugins.append((plugin, mark_safe(content + view))) elif content: enabled_plugins.append((plugin, mark_safe(content))) else: other_plugins.append(plugin) context = { 'page': 'notifications', 'enabled_plugins': enabled_plugins, 'other_plugins': other_plugins, 'general_form': general_form, } return self.respond('sentry/project-notifications.html', context)