예제 #1
0
  def show(self):
    self.template = 'admin/index'
    client = gdata.spreadsheets.client.SpreadsheetsClient(source='Devfest-Website-v1')
    access_token = gdata.gauth.AeLoad('spreadsheed_token')
    feed = client.get_list_feed(self.settings.DOCSAPI_SPREADSHEET_ID,
                                self.settings.DOCSAPI_SPREADSHEET_WORKSHEET_ID,
                                auth_token=access_token)
    if feed.entry:
      for entry in feed.entry:
        ev = entry.to_dict()
        original_users = ev['organizerse-mailid'].split(',')
        event_users = []
        for user in original_users:
          event_users.append(users.User(user.strip()))

        event = Event()
        event.user = event_users
        event.location = "%s, %s" % (ev['city'], ev['country'])
        event.gdg_chapters = [ev['gdgchaptername']]
        event.subdomain = ev['preferredsubdomainfortheeventwebsite']
        event.expected_participants = ev['expectednumberofparticipants']
        event.kind_of_support = ev['whatkindofsupportyouexpectforthisevent']
        event.approved = True
        try:
          event.start = datetime.strptime(ev['eventdate'], '%m/%d/%Y')
        except:
          pass

        event.put()
예제 #2
0
  def save_to_gdrive(self):
    import gdata.gauth
    import gdata.docs.client
    import gdata.spreadsheets.client

    client = gdata.spreadsheets.client.SpreadsheetsClient(source='Devfest-Website-v1')
    access_token = gdata.gauth.AeLoad('spreadsheed_token')
    feed = client.get_list_feed(settings.DOCSAPI_SPREADSHEET_ID, settings.DOCSAPI_SPREADSHEET_EXPORT_WORKSHEET_ID, auth_token=access_token)

    organizers = []
    for organizer in self.organizers:
      organizers.append(organizer.email())

    agenda = []
    for agenda_entry in self.agenda:
      if agenda_entry == '1':
        agenda.append('Conference')
      elif agenda_entry == '2':
        agenda.append('Hackathon')
      elif agenda_entry == '3':
        agenda.append('Barcamp')
      elif agenda_entry == '4':
        agenda.append('GDL Sessions')
      elif agenda_entry == '5':
        agenda.append('Others')

    eventdate = ''
    if self.start is not None:
      eventdate = "%s" % self.start.strftime('%m/%d/%Y %H:%M:%S')
    if self.end is not None:
      eventdate = "%s - %s" % (eventdate, self.end.strftime('%m/%d/%Y %H:%M:%S'))

    data = {
        'timestamp': datetime.datetime.utcnow().strftime('%m/%d/%Y %H:%M:%S'),
        'gdgchaptername': ', '.join(self.gdg_chapters),
        'country': self.country,
        'eventdate': eventdate,
        'organizerse-mailid': ', '.join(organizers),
        'whatareyouplanningtodo': ', '.join(agenda),
        'whatproductstechnologiesyouproposetocoverintheevent': ', '.join(self.technologies),
        'whatkindofsupportyouexpectforthisevent': self.kind_of_support,
        'expectednumberofparticipants': '%s' % self.expected_participants,
        'city': self.city,
        'preferredsubdomainfortheeventwebsite': self.subdomain,
        'eventwebsiteforyourgdgdevfest': self.gplus_event_url,
        'registrationpagefortheevent': self.register_url
        }
    entry = gdata.spreadsheets.data.ListEntry()
    entry.from_dict(data)
    client.add_list_entry(entry, settings.DOCSAPI_SPREADSHEET_ID, settings.DOCSAPI_SPREADSHEET_EXPORT_WORKSHEET_ID, auth_token=access_token)