How to use the pretalx.event.models.Event.objects function in pretalx

To help you get started, we’ve selected a few pretalx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pretalx / pretalx / src / pretalx / agenda / tasks.py View on Github external
def export_schedule_html(*, event_id: int, make_zip=True):
    from django.core.management import call_command

    with scopes_disabled():
        event = (
            Event.objects.prefetch_related("submissions").filter(pk=event_id).first()
        )
    if not event:
        LOGGER.error(f"In export_schedule_html: Could not find Event ID {event_id}")
        return

    with scope(event=event):
        if not event.current_schedule:
            LOGGER.error(
                f"In export_schedule_html: Event {event.slug} has no schedule."
            )
            return

    cmd = ["export_schedule_html", event.slug]
    if make_zip:
        cmd.append("--zip")
    call_command(*cmd)
github pretalx / pretalx / src / pretalx / cfp / views / event.py View on Github external
def get_context_data(self, **kwargs):
        result = super().get_context_data(**kwargs)
        _now = now().date()
        qs = Event.objects.order_by("-date_to")
        result["current_events"] = self.filter_events(
            qs.filter(date_from__lte=_now, date_to__gte=_now)
        )
        result["past_events"] = self.filter_events(qs.filter(date_to__lt=_now))
        result["future_events"] = self.filter_events(qs.filter(date_from__gt=_now))
        return result
github pretalx / pretalx / src / pretalx / event / forms.py View on Github external
def copy_from_queryset(user):
        return Event.objects.filter(
            Q(
                organiser_id__in=user.teams.filter(
                    all_events=True, can_change_event_settings=True
                ).values_list("organiser", flat=True)
            )
            | Q(
                id__in=user.teams.filter(can_change_event_settings=True).values_list(
                    "limit_events__id", flat=True
                )
github pretalx / pretalx / src / pretalx / common / middleware / event.py View on Github external
def _set_orga_events(request):
        request.is_orga = False
        request.is_reviewer = False
        request.orga_events = []
        if not request.user.is_anonymous:
            if request.user.is_administrator:
                request.orga_events = Event.objects.order_by("date_from")
                request.is_orga = True
                request.is_reviewer = True
            else:
                request.orga_events = request.user.get_events_for_permission().order_by(
                    "date_from"
                )
                event = getattr(request, "event", None)
                if event:
                    request.is_orga = event in request.orga_events
                    request.is_reviewer = event.teams.filter(
                        members__in=[request.user], is_reviewer=True
                    ).exists()
github pretalx / pretalx / src / pretalx / api / views / event.py View on Github external
from django.http import Http404
from rest_framework import viewsets

from pretalx.api.serializers.event import EventSerializer
from pretalx.event.models import Event


class EventViewSet(viewsets.ReadOnlyModelViewSet):
    serializer_class = EventSerializer
    queryset = Event.objects.none()
    lookup_field = "slug"
    lookup_url_kwarg = "event"
    pagination_class = None
    permission_required = "cfp.view_event"

    def get_queryset(self):
        return [
            e
            for e in Event.objects.all()
            if self.request.user.has_perm(self.permission_required, e)
        ]

    def get_object(self):
        if self.request.user.has_perm(self.permission_required, self.request.event):
            return self.request.event
        raise Http404()
github pretalx / pretalx / src / pretalx / event / forms.py View on Github external
def clean_slug(self):
        slug = self.cleaned_data["slug"]
        qs = Event.objects.all()
        if qs.filter(slug__iexact=slug).exists():
            raise forms.ValidationError(
                _(
                    "This short name is already taken, please choose another one (or ask the owner of that event to add you to their team)."
                )
            )

        return slug.lower()
github pretalx / pretalx / src / pretalx / api / views / event.py View on Github external
def get_queryset(self):
        return [
            e
            for e in Event.objects.all()
            if self.request.user.has_perm(self.permission_required, e)
        ]
github pretalx / pretalx / src / pretalx / event / services.py View on Github external
def periodic_event_services(sender, **kwargs):
    for event in Event.objects.all():
        with scope(event=event):
            task_periodic_event_services.apply_async(args=(event.slug,))
            if event.current_schedule:
                task_periodic_schedule_export.apply_async(args=(event.slug,))
            event.update_review_phase()
github pretalx / pretalx / src / pretalx / agenda / management / commands / export_schedule_html.py View on Github external
def handle(self, *args, **options):
        event_slug = options.get("event")

        with scopes_disabled():
            try:
                event = Event.objects.get(slug__iexact=event_slug)
            except Event.DoesNotExist:
                raise CommandError(f'Could not find event with slug "{event_slug}".')

        with scope(event=event):
            logging.info(f"Exporting {event.name}")
            export_dir = get_export_path(event)
            zip_path = get_export_zip_path(event)
            tmp_dir = export_dir.with_name(export_dir.name + "-new")

            delete_directory(tmp_dir)
            tmp_dir.mkdir()

            try:
                export_event(event, tmp_dir)
                delete_directory(export_dir)
                tmp_dir.rename(export_dir)
github pretalx / pretalx / src / pretalx / common / tasks.py View on Github external
def regenerate_css(event_id: int):
    event = Event.objects.filter(pk=event_id).first()
    local_apps = ["agenda", "cfp"]
    if not event:
        logger.error(f"In regenerate_css: Event ID {event_id} not found.")
        return

    if event.settings.widget_css_checksum:
        generate_widget_css(event)
    for locale in event.locales:
        if event.settings.get(f"widget_checksum_{locale}"):
            generate_widget_js(event, locale)

    if not event.primary_color:
        for local_app in local_apps:
            event.settings.delete(f"{local_app}_css_file")
            event.settings.delete(f"{local_app}_css_checksum")
        return