Example #1
0
    def fill(kls, account):
        from webinars_web.webinars import models as wm
        now = time()
        events = account.webex_account.events
        local_events = dict((e.remote_id, e) for e in wm.Event.objects.filter(account=account, deleted_at__isnull=True) if e.remote_id)
        with kls.delayed as d:
            for event in events:
                raw_event = dict(
                    account_id = account.id,
                    title = event.title,
                    description = event.description,
                    _timezone = event.starts_at.tz_name,
                    _time_starts_at = nint(ntime(event._starts_at)),
                    _time_ends_at = nint(ntime(event._ends_at)),
                    _time_started_at = nint(ntime(event._started_at)),
                    _time_ended_at = nint(ntime(event._ended_at)),
                    session_key  = event.session_key )

                # if customer is automatically deleting events on webex side, then we make it seem like they haven't (so we don't start pumping NULLs into ends_at and starts_at)
                local_event = local_events.get(event.session_key)
                if local_event and local_event._ends_at and now > local_event._ends_at:
                    raw_event['_time_starts_at'] = int(local_event._time_starts_at)
                    raw_event['_time_ends_at'] = int(local_event._time_ends_at)
                    raw_event['_timezone'] = local_event._timezone
                raw_event['hashcode'] = kls.calc_hashcode(**raw_event)
                d.insert(raw_event)
        from django.db import transaction
        transaction.commit_unless_managed()
        return len(events)
Example #2
0
 def __init__(self, hub, **kwargs):
     super(Setting, self).__init__()
     self.hub = hub
     self.name = kwargs.get('name')
     self.value = kwargs.get('value')
     self.app_key = mget(kwargs,'app_key','appKey')
     self.created_at = ntime(ms=kwargs.get('createdAt')) or kwargs.get('created_at')
     self.updated_at = ntime(ms=kwargs.get('updatedAt')) or kwargs.get('updated_at')
     self.readonly = kwargs.get('readonly',False)
     hub_id = mget(kwargs,'hub_id','portal_id','portalId')
     if hub_id: 
         if not hub.id: hub.id = hub_id
         elif hub_id!=hub.id: raise Exception('wtf-- that shouldnt have happened -- hub.id=%s , hub_id=%s' % (hub.id, hub_id))
Example #3
0
    def __init__(self, webinar, **kwargs):
        super(Session, self).__init__()
        self.webinar = webinar
        self.key = mget(kwargs,'sessionKey','key')
        self.attendant_count = mget(kwargs, 'attendant_count', 'registrantsAttended')
        if kwargs.has_key('attendees'): self.attendees = kwargs['attendees']

        actual = kwargs.get('actual')
        scheduled = kwargs.get('scheduled')
        self._starts_at = ntime(mget(kwargs,'starts_at','_starts_at') or scheduled and kwargs.get('startTime'))
        self._ends_at = ntime(mget(kwargs,'ends_at','_ends_at') or scheduled and kwargs.get('endTime'))
        self._started_at = ntime(mget(kwargs,'started_at','_started_at') or actual and kwargs.get('startTime'))
        self._ended_at = ntime(mget(kwargs,'ended_at','_ended_at') or actual and kwargs.get('endTime'))
Example #4
0
 def __init__(self, **kwargs):
     super(Registrant, self).__init__()
     self.webinar = kwargs.get('webinar')
     self.session = kwargs.get('session')
     self.key = mget(kwargs, 'key', 'registrant_key', 'registrantKey')
     self.email = nlower(mget(kwargs, 'email', 'attendeeEmail'))
     self.first_name = mget(kwargs, 'first_name', 'firstName', 'first')
     self.last_name = mget(kwargs, 'last_name', 'lastName', 'last')
     if kwargs.get('name'): self.name = nstrip(kwargs.get('name'))
     self.registered_at = ntime(
         mget(kwargs, 'registered_at', 'registrationDate'))
     self.join_url = mget(kwargs, 'join_url', 'joinUrl')
     self.status = kwargs.get('status')
     self.viewings = kwargs.get('viewings', [])
     if not self.viewings and kwargs.get('attendance'):
         self.viewings = sort([(time(d['joinTime']), time(d['leaveTime']))
                               for d in kwargs['attendance']])
     if not self.viewings and (
             kwargs.get('duration') or kwargs.get('attendanceTimeInSeconds')
     ) and self.session and self.session.key and self.session.started_at:
         duration = kwargs.get(
             'duration') or kwargs.get('attendanceTimeInSeconds') and delta(
                 s=kwargs['attendanceTimeInSeconds'])
         self.viewings = [(self.session.started_at,
                           self.session.started_at + duration)]
Example #5
0
    def __init__(self, webinar, **kwargs):
        super(Session, self).__init__()
        self.webinar = webinar
        self.key = mget(kwargs, 'sessionKey', 'key')
        self.attendant_count = mget(kwargs, 'attendant_count',
                                    'registrantsAttended')
        if kwargs.has_key('attendees'): self.attendees = kwargs['attendees']

        actual = kwargs.get('actual')
        scheduled = kwargs.get('scheduled')
        self._starts_at = ntime(
            mget(kwargs, 'starts_at', '_starts_at')
            or scheduled and kwargs.get('startTime'))
        self._ends_at = ntime(
            mget(kwargs, 'ends_at', '_ends_at')
            or scheduled and kwargs.get('endTime'))
        self._started_at = ntime(
            mget(kwargs, 'started_at', '_started_at')
            or actual and kwargs.get('startTime'))
        self._ended_at = ntime(
            mget(kwargs, 'ended_at', '_ended_at')
            or actual and kwargs.get('endTime'))
Example #6
0
 def __init__(self, **kwargs):
     super(Registrant, self).__init__()
     self.webinar = kwargs.get('webinar')
     self.session = kwargs.get('session')
     self.key = mget(kwargs, 'key', 'registrant_key', 'registrantKey')
     self.email = nlower(mget(kwargs, 'email', 'attendeeEmail'))
     self.first_name = mget(kwargs, 'first_name', 'firstName', 'first')
     self.last_name = mget(kwargs, 'last_name', 'lastName', 'last')
     if kwargs.get('name'): self.name = nstrip(kwargs.get('name'))
     self.registered_at = ntime(mget(kwargs, 'registered_at', 'registrationDate'))
     self.join_url = mget(kwargs, 'join_url', 'joinUrl')
     self.status = kwargs.get('status')
     self.viewings = kwargs.get('viewings',[])
     if not self.viewings and kwargs.get('attendance'):
         self.viewings = sort([(time(d['joinTime']),time(d['leaveTime'])) for d in kwargs['attendance']])
     if not self.viewings and (kwargs.get('duration') or kwargs.get('attendanceTimeInSeconds')) and self.session and self.session.key and self.session.started_at:
         duration = kwargs.get('duration') or kwargs.get('attendanceTimeInSeconds') and delta(s=kwargs['attendanceTimeInSeconds'])
         self.viewings = [(self.session.started_at, self.session.started_at+duration)]