當前位置: 首頁>>代碼示例>>Python>>正文


Python models.Event類代碼示例

本文整理匯總了Python中core.models.Event的典型用法代碼示例。如果您正苦於以下問題:Python Event類的具體用法?Python Event怎麽用?Python Event使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Event類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_or_create_dummy

    def get_or_create_dummy(cls):
        from django.contrib.auth.models import Group
        from core.models import Event

        group, unused = Group.objects.get_or_create(name='Dummy ticket admin group')
        event, unused = Event.get_or_create_dummy()
        return cls.objects.get_or_create(event=event, defaults=dict(admin_group=group))
開發者ID:wyrmiyu,項目名稱:kompassi,代碼行數:7,代碼來源:models.py

示例2: get_or_create_dummies

    def get_or_create_dummies(cls):
        from core.models import Event
        event, unused = Event.get_or_create_dummy()
        jc1, unused = cls.objects.get_or_create(event=event, name="Dummy 1", slug='dummy-1')
        jc2, unused = cls.objects.get_or_create(event=event, name="Dummy 2", slug='dummy-2')

        return [jc1, jc2]
開發者ID:Hilzu,項目名稱:kompassi,代碼行數:7,代碼來源:job_category.py

示例3: get_or_create_dummy

    def get_or_create_dummy(cls):
        from core.models import Event

        event, unused = Event.get_or_create_dummy()
        admin_group, hosts_group = cls.get_or_create_groups(event, ["admins", "hosts"])

        return cls.objects.get_or_create(event=event, defaults=dict(admin_group=admin_group, public=True))
開發者ID:Hilzu,項目名稱:kompassi,代碼行數:7,代碼來源:programme_event_meta.py

示例4: get_or_create_dummy

 def get_or_create_dummy(cls):
     from core.models import Event
     event, unused = Event.get_or_create_dummy()
     return cls.objects.get_or_create(
         event=event,
         name='Iso sali',
     )
開發者ID:tracon,項目名稱:kompassi,代碼行數:7,代碼來源:room.py

示例5: get_or_create_dummies

    def get_or_create_dummies(cls):
        from core.models import Event
        event, unused = Event.get_or_create_dummy()

        limit_saturday, unused = cls.objects.get_or_create(event=event, description='Testing saturday', defaults=dict(limit=5000))
        limit_sunday, unused = cls.objects.get_or_create(event=event, description='Testing sunday', defaults=dict(limit=5000))

        return [limit_saturday, limit_sunday]
開發者ID:wyrmiyu,項目名稱:kompassi,代碼行數:8,代碼來源:models.py

示例6: get_or_create_dummy

 def get_or_create_dummy(cls):
     from core.models import Event
     event, unused = Event.get_or_create_dummy()
     admin_group, organizer_group = cls.get_or_create_groups(event, ['admins', 'organizers'])
     return cls.objects.get_or_create(event=event, defaults=dict(
         admin_group=admin_group,
         organizer_group=organizer_group,
     ))
開發者ID:tracon,項目名稱:kompassi,代碼行數:8,代碼來源:intra_event_meta.py

示例7: save_event_to_db

def save_event_to_db(event):
    '''The function to save single event into DB (table: core_event)
    '''
    e = Event(
        categoryID             = parse_category_id(event['category_id']),
        datePosted             = parse_datetime(event['date_posted']),
        description            = event['description'],
        distance               = event['distance'],
        distanceUnits          = event['distance_units'],
        endDate                = parse_date(event['end_date']),
        endTime                = parse_time(event['end_time']),
        geoCodingAmbig         = event['geocoding_ambiguous'],
        geoCodingPrec          = event['geocoding_precision'],
        eventID                = event['id'],
        latitude               = event['latitude'],
        longitude              = event['longitude'],
        metroID                = event['metro_id'],
        name                   = event['name'],
        numFutureEvents        = event['num_future_events'],
        personal               = event['personal'],
        photoURL               = event['photo_url'],
        selfPromotion          = event['selfpromotion'],
        startDate              = parse_date(event['start_date']),
        startDateLastRendition = event['start_date_last_rendition'],
        startTime              = parse_time(event['start_time']),
        ticketFree             = parse_int(event['ticket_free']),
        ticketPrice            = event['ticket_price'],
        ticketURL              = event['ticket_url'],
        URL                    = event['url'],
        userID                 = event['user_id'],
        utcEnd                 = parse_datetime(event['utc_end']),
        utcStart               = parse_datetime(event['utc_start']),
        venueAddr              = event['venue_address'],
        venueCity              = event['venue_city'],
        venueCountryCode       = event['venue_country_code'],
        venueCountryID         = event['venue_country_id'],
        venueCountryName       = event['venue_country_name'],
        venueID                = event['venue_id'],
        venueName              = event['venue_name'],
        venueStateCode         = event['venue_state_code'],
        venueStateID           = event['venue_state_id'],
        venueStateName         = event['venue_state_name'],
        venueZip               = str(event['venue_zip']),
        watchListCount         = event['watchlist_count'])
    e.save()
開發者ID:JohnStuartRutledge,項目名稱:django-insightfever,代碼行數:45,代碼來源:UpcomingCrawler.py

示例8: test_event_filter

    def test_event_filter(self):
        event, unused = Event.get_or_create_dummy()
        event2, unused = Event.get_or_create_dummy(name='Dummy event 2')

        kwargs = dict(
            channel='callback',
            callback_code=f'{__name__}:notification_callback',
        )

        subscription_with_event_filter, unused = Subscription.get_or_create_dummy(event_filter=event, **kwargs)
        subscription_without_event_filter, unused = Subscription.get_or_create_dummy(event_filter=None, **kwargs)

        entry_type = subscription_with_event_filter.entry_type

        emit(entry_type, event=event)
        emit(entry_type, event=event2)

        assert len(notifications) == 3
開發者ID:Siikakala,項目名稱:kompassi,代碼行數:18,代碼來源:tests.py

示例9: setUp

    def setUp(self):
        app = get_application()
        self.client = Client(app, BaseResponse)

        self.test_values = {
            'date': datetime.datetime(2016, 5, 20, 15, 0),
            'title': 'THIS IS TITLE',
            'description': 'THIS IS TITLE',
        }

        eve = Event(
            event_date=self.test_values['date'],
            title=self.test_values['title'],
            description=self.test_values['description'],
        )
        eve.put()
        events = Event.all().fetch(100)
        self.assertEquals(len(events), 1)
        self.assertEquals(events[0].title, 'THIS IS TITLE')
        self.event_key = str(events[0].key())
開發者ID:yosukesuzuki,項目名稱:calendar-app,代碼行數:20,代碼來源:test_views.py

示例10: get_or_create_dummy

    def get_or_create_dummy(cls, app_label='labour', name='Smallfolk', priority=0):
        from core.models import Event
        event, unused = Event.get_or_create_dummy()

        return PersonnelClass.objects.get_or_create(
            event=event,
            slug=slugify(name),
            app_label=app_label,
            defaults=dict(
                name=app_label,
                priority=priority,
            )
        )
開發者ID:Siikakala,項目名稱:kompassi,代碼行數:13,代碼來源:personnel_class.py

示例11: events

def events(request):
    if request.user.is_anonymous():
        return JsonResponse({'error': 'loggedOut'})

    if request.method == 'POST':
        event_data = convert_dict_keys_deep(json.loads(request.body))['event']
        if (not event_data['name'] or not event_data['date_from'] or not event_data['type'] or not event_data['color']):
            return JsonResponse({'error': 'badRequest'})

        if (not event_data['id']):
            event = Event(
                name=event_data['name'],
                date_from=event_data['date_from'],
                date_to=event_data['date_to'],
                type=event_data['type'],
                color=event_data['color'],
            )
            event.save()
            return JsonResponse({'event': serialize_event(event)})

    events = [serialize_event(event) for event in Event.objects.order_by('date_from').all()]
    return JsonResponse({'events': events})
開發者ID:briska,項目名稱:bemyguest,代碼行數:22,代碼來源:api.py

示例12: get_or_create_dummy

    def get_or_create_dummy(cls, event=None):
        from django.contrib.auth.models import Group
        from core.models import Event

        if event is None:
            event, unused = Event.get_or_create_dummy()

        group, = PaymentsEventMeta.get_or_create_groups(event, ['admins'])

        return cls.objects.get_or_create(event=event, defaults=dict(
            EVENT_META_DEFAULTS,
            admin_group=group,
        ))
開發者ID:Hilzu,項目名稱:kompassi,代碼行數:13,代碼來源:models.py

示例13: get_or_create_dummy

    def get_or_create_dummy(cls):
        from core.models import Event
        from django.utils.timezone import now

        event, unused = Event.get_or_create_dummy()
        admin_group, hosts_group = cls.get_or_create_groups(event, ['admins', 'hosts'])

        return cls.objects.get_or_create(
            event=event,
            defaults=dict(
                admin_group=admin_group,
                public_from=now(),
            )
        )
開發者ID:Siikakala,項目名稱:kompassi,代碼行數:14,代碼來源:programme_event_meta.py

示例14: ical

def ical(request, event_key):
    event = Event.get(event_key)
    if event is None:
        return render_json_response({'error': '404 not found'}, mimetype='application/json', status=404)
    cal = icalendar.Calendar()
    eve = icalendar.Event()
    eve['dtstart'] = event.event_date.strftime('%Y%m%dT%H%M%S')
    eve['created'] = event.created_at.strftime('%Y%m%dT%H%M%S')
    eve['last-modified'] = event.updated_at.strftime('%Y%m%dT%H%M%S')
    eve['summary'] = event.title
    eve['description'] = event.description
    eve['event_key'] = event_key
    eve['updated_log'] = event.updated_log
    cal.add_component(eve)
    return Response(cal.to_ical(), status=200, mimetype="text/calendar",
                    headers={'Content-Disposition': 'inline; filename=event.ics'})
開發者ID:yosukesuzuki,項目名稱:calendar-app,代碼行數:16,代碼來源:views.py

示例15: api_event_add

def api_event_add(request):
    response = {}
    header = request.POST['header']
    category = request.POST['category']
    plan_id = request.POST['plan_id']
    plan = Plan.objects.get(id=plan_id)
    new_event = Event()
    new_event.header = header
    new_event.category = category
    new_event.plan = plan
    new_event.order = len(plan.get_events())
    new_event.save()
    response['event_id'] = new_event.id
    response['collaborator_id'] = request.user.id
    return response, 201
開發者ID:elesant,項目名稱:TripPlanner,代碼行數:15,代碼來源:views.py


注:本文中的core.models.Event類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。