Exemplo n.º 1
0
def sync_session_gcal(session, delete=False):
  '''
  Sync a SportSession on Google calendar
  '''
  from sport.gcal import GCalSync

  # Check the user has gcal
  user = session.day.week.user
  if not user.has_gcal():
    return

  # Start sync
  gc = GCalSync(user)
  if delete and session.gcal_id:
    gc.delete_event(session.gcal_id)
  else:
    gc.sync_sport_session(session)
Exemplo n.º 2
0
Arquivo: tasks.py Projeto: La0/coach
def sync_session_gcal(session, delete=False):
    """
  Sync a SportSession on Google calendar
  """
    from sport.gcal import GCalSync

    # Check the user has gcal
    user = session.day.week.user
    if not user.has_gcal():
        return

    # Start sync
    gc = GCalSync(user)
    if delete and session.gcal_id:
        gc.delete_event(session.gcal_id)
    else:
        gc.sync_sport_session(session)
Exemplo n.º 3
0
def sync_gcal(user):
  '''
  Sync all the user sport sessions
  when creating a new calendar
  '''
  if not user.has_gcal():
    return

  from sport.gcal import GCalSync
  from sport.models import SportSession

  sessions = SportSession.objects.filter(day__week__user=user)
  sessions = sessions.filter(gcal_id__isnull=True)
  sessions = sessions.order_by('-day__date')

  gc = GCalSync(user)
  for s in sessions:
    try:
      gc.sync_sport_session(s)
    except Exception, e:
      print 'Failed to create an event: %s' % (str(e), )
Exemplo n.º 4
0
Arquivo: tasks.py Projeto: La0/coach
def sync_gcal(user):
    """
  Sync all the user sport sessions
  when creating a new calendar
  """
    if not user.has_gcal():
        return

    from sport.gcal import GCalSync
    from sport.models import SportSession

    sessions = SportSession.objects.filter(day__week__user=user)
    sessions = sessions.filter(gcal_id__isnull=True)
    sessions = sessions.order_by("-day__date")

    gc = GCalSync(user)
    for s in sessions:
        try:
            gc.sync_sport_session(s)
        except Exception, e:
            print "Failed to create an event: %s" % (str(e),)