def get(self): user = users.get_current_user() logout_url = users.create_logout_url(self.request.uri) login_url = users.create_login_url(self.request.uri) # raise NotAllowedError profile='' if user: profile = Profile.query(Profile.user_id==user.user_id()) if profile.count() <= 0: profile = Profile() profile.user_id = user.user_id() profile.email = user.email() profile.firstname = user.nickname() profile_key = profile.put() else: profile_key = Profile.query(Profile.user_id==user.user_id()) profile = profile_key.get() current_user = '******'+ user.nickname() user_url = logout_url title = "Click to logout from Google." else: current_user = '******' user_url = login_url title = "Click to sign in with your Google Account." values = { 'current_user' : current_user, 'user_url' : user_url, 'profile' : profile, } self.render_html('index.html',values)
def get_profile(): user = users.get_current_user() if user: user_id = user.user_id() p_key = ndb.Key(Profile, user_id) profile = p_key.get() # create a Profile if not found if not profile: profile = Profile( key=p_key, nickName=user.nickname(), eMail=user.email(), ) profile.put() return profile else: return None
def config(): profile = Profile(name = "Wallowsss") profile.title = "...a geek dreamer..." profile.subtitle = "I'm a human that promised to himself that will realize all dreams that had been dreamed." profile.description = "I'm starting again in my professional life as trainee of an important global consulting, before that I was a Programmer Analyst. Studying information security mobile, project management, some programming languages and all important things that I'm sure are bringing benefits to my growth." profile.put() services = Services(service = "Twitter") services.tumbnail = "/images/twitter.png" services.link = "http://www.twitter.com/wallowsss" services.put() services = Services(service = "Facebook") services.tumbnail = "/images/facebook.png" services.link = "http://www.facebook.com/wallowsss" services.put() services = Services(service = "Google Plus") services.tumbnail = "/images/gplus.png" services.link = "http://www.google.com/profiles/coutinho90" services.put() services = Services(service = "Linkedin") services.tumbnail = "/images/linkedin.png" services.link = "http://br.linkedin.com/in/wallacebarbosa" services.put()
def text_message(self, message): access_token_key = 'access_token_%s' % message.sender.partition('/')[0] access_token = gdata.gauth.ae_load(access_token_key) gcal.auth_token = access_token if message.body.startswith('.'): current_calendar = message.body.lstrip('.').strip() feed = gcal.GetOwnCalendarsFeed() gdata.calendar.data.CalendarEntry for i, a_calendar in enumerate(feed.entry): if a_calendar.title.text == current_calendar: query = db.GqlQuery( "SELECT * FROM Profile WHERE email = :1", message.sender.partition('/')[0]) profiles = query.fetch(100) for profile in profiles: profile.current_calendar = current_calendar profile.save() xmpp.send_message( jids=message.sender, body='Current calendar switched to %s' % profile.current_calendar, from_jid="*****@*****.**") return profile = Profile( email = message.sender.partition('/')[0], current_calendar = current_calendar) profile.put() xmpp.send_message( jids=message.sender, body='Current calendar switched to %s' % profile.current_calendar, from_jid="*****@*****.**") return xmpp.send_message(jids=message.sender, body='calendar not found', from_jid="*****@*****.**") return format = '%Y-%m-%dT%H:%M:%S.000Z' start_time = time.gmtime() end_time = time.gmtime(time.time() + 3600) str_start_time = time.strftime(format, start_time) str_end_time = time.strftime(format, end_time) prev_event_end_time = time.gmtime(time.time() - 60) profile = Profile.all().filter("email =", message.sender.partition('/')[0]).get() event = gdata.calendar.data.CalendarEventEntry() event.title = atom.data.Title(text=message.body) event.content = atom.data.Content(text="createdby:talk") event.when.append(gdata.calendar.data.When(start=str_start_time, end=str_end_time)) own_calendars_feed = gcal.GetOwnCalendarsFeed() if (profile is None): event = gcal.InsertEvent(event) else: for i, a_calendar in enumerate(own_calendars_feed.entry): if (profile.current_calendar == a_calendar.title.text): calendar_id = a_calendar.link[0].href calendar_event_feed = gcal.get_calendar_event_feed(uri=calendar_id) event = gcal.InsertEvent(event, insert_uri=calendar_id) for when in event.when: str_start_time = when.start str_end_time = when.end query = gdata.calendar.client.CalendarEventQuery() query.start_max = str_start_time #fix latest event for i, a_calendar in enumerate(own_calendars_feed.entry): calendar_id = a_calendar.link[0].href calendar_event_feed = gcal.get_calendar_event_feed(uri=calendar_id, q=query) for i, an_event in enumerate(calendar_event_feed.entry): for a_when in an_event.when: if a_when.end >= str_start_time and an_event.content.text is not None and "createdby:talk" in an_event.content.text: try: a_when.end = time.strftime(format, prev_event_end_time) gcal.Update(an_event) except: continue xmpp.send_message(jids=message.sender, body=message.body, from_jid="*****@*****.**")