Example #1
0
    def get(self):
        self.response.write('Welcome to attender server! Here is a cron job for pulling events from sorces: meetup.com and evenbrite.com')

        ev = Event()
        at = Attendings()
        logging.info("Adding new events to DataStore")
        results = self.obj.request_events(radius="25")
        logging.info("Events added: {}".format(results))
        logging.info("Deleting old events from DataStore")

        #Delete passed events
        qe = ev.return_all_events()
        results = qe.filter(Event.date < datetime.now())
        for res in results:
            logging.info(str(res.key.id()))
            old_attending = Attendings.query(Attendings.event_id == int(res.key.id())).get()
            logging.info("query {}".format(old_attending))
            if old_attending is not None:
                old_attending.key.delete()
            res.key.delete()


        #Update city names
        for q in qe:
            changed = self.api_obj.check_city(q.city)
            if changed:
                q.city = changed
                q.put()
Example #2
0
 def unattend(u_key, e_key):
     event1 = Event()
     qry = User.get_by_id(u_key)
     if qry is None:
         return 1
     if Event.get_by_id(e_key) is None:
         return 2
     attendings1 = Attendings()
     q = attendings1.check_attend_exist(u_key, e_key)
     if q:
         q.key.delete()
         event1.update_attendees(e_key, action="sub")
     return 0
Example #3
0
 def unattend(u_key, e_key):
     event1 = Event()
     qry = User.get_by_id(u_key)
     if qry is None:
         return 1
     if Event.get_by_id(e_key) is None:
         return 2
     attendings1 = Attendings()
     q = attendings1.check_attend_exist(u_key, e_key)
     if q:
         q.key.delete()
         event1.update_attendees(e_key, action="sub")
     return 0
Example #4
0
 def get_all_user_events(self, u_id):
     events_list = []
     results = Attendings.query(Attendings.user_id == u_id)
     for res in results:
         if self.get_event_details(res.event_id) is not None:
             events_list.append(self.get_event_details(res.event_id))
     return json.dumps(events_list)
Example #5
0
 def get_all_user_events(self, u_id):
     events_list = []
     results = Attendings.query(Attendings.user_id == u_id)
     for res in results:
         if self.get_event_details(res.event_id) is not None:
             events_list.append(self.get_event_details(res.event_id))
     return json.dumps(events_list)
    def get(self):
        self.response.write('Welcome to attender server! Here is a cron job for pulling events from sorces: meetup.com and evenbrite.com')

        ev = Event()
        at = Attendings()
        logging.info("Adding new events to DataStore")
        results = self.obj.request_events(radius="25")
        logging.info("Events added: {}".format(results))
        logging.info("Deleting old events from DataStore")

        #Delete passed events
        qe = ev.return_all_events()
        results = qe.filter(Event.date < datetime.now())
        for res in results:
            logging.info(str(res.key.id()))
            old_attending = Attendings.query(Attendings.event_id == int(res.key.id())).get()
            logging.info("query {}".format(old_attending))
            if old_attending is not None:
                old_attending.key.delete()
            res.key.delete()


        #Update city names
        for q in qe:
            changed = self.api_obj.check_city(q.city)
            if changed:
                q.city = changed
                q.put()
Example #7
0
 def get_attendings(self, ev_id, user_id, fb_token=None):
     us = User.get_by_id(user_id)
     token = None
     fb_id = None
     if us is not None:
         fb_id = us.fb_id
     if Event.get_by_id(ev_id) is None:
         return 1
     results = Attendings.query(Attendings.event_id == ev_id)
     return self.json_format_attendees(results, fb_token, fb_id, user_id)
Example #8
0
 def get_attendings(self, ev_id, user_id, fb_token=None):
     us = User.get_by_id(user_id)
     token = None
     fb_id = None
     if us is not None:
         fb_id = us.fb_id
     if Event.get_by_id(ev_id) is None:
         return 1
     results = Attendings.query(Attendings.event_id == ev_id)
     return self.json_format_attendees(results, fb_token, fb_id, user_id)
Example #9
0
    def attend(u_key, e_key):
        event1 = Event()
        attendings1 = Attendings()

        qry = User.get_by_id(u_key)
        logging.info("query is : {}".format(qry))
        if qry is None:
            return 1
        else:
            attendings1.user_id = u_key
        if Event.get_by_id(e_key) is None:
            return 2
        else:
            attendings1.event_id = e_key
        if attendings1.check_attend_exist(u_key, e_key) is False:
            attendings1.put()
            event1.update_attendees(e_key, action="add")
        return 0
Example #10
0
 def set_event_details(e_id, name, date, city,  add, descr, host, url, attendees, price, category, source):
     event1 = Event()
     qry = event1.check_event_exist(e_id) or event1.check_event_exist_by_name(name)
     if qry is False:
         event1.id = e_id
         event1.name = name
         event1.date = date
         event1.city = city
         event1.address = add
         event1.description = descr
         event1.host = host
         event1.event_url = url
         event1.source = source
         if (attendees != "Unknown"):
             event1.attendees = attendees
         event1.price = price
         if category is not None:
             event1.category = category
         key = event1.put()
         return key
     else:  # Update existing meetings! It could be changed or canceled!
         qry.name = name
         qry.date = date
         qry.city = city
         qry.address = add
         qry.description = descr
         qry.host = host
         qry.event_url = url
         qry.source = source
         qry.price = price
         if category is not None:
             qry.category = category
         results = Attendings.query(Attendings.event_id == qry.get_by_id(e_id))
         if results is not None:
             qry.attendees = attendees + results.count()
         else:
             qry.attendees = attendees
         qry.put()
Example #11
0
 def set_event_details(e_id, name, date, city,  add, descr, host, url, attendees, price, category, source):
     event1 = Event()
     qry = event1.check_event_exist(e_id) or event1.check_event_exist_by_name(name)
     if qry is False:
         event1.id = e_id
         event1.name = name
         event1.date = date
         event1.city = city
         event1.address = add
         event1.description = descr
         event1.host = host
         event1.event_url = url
         event1.source = source
         if (attendees != "Unknown"):
             event1.attendees = attendees
         event1.price = price
         if category is not None:
             event1.category = category
         key = event1.put()
         return key
     else:  # Update existing meetings! It could be changed or canceled!
         qry.name = name
         qry.date = date
         qry.city = city
         qry.address = add
         qry.description = descr
         qry.host = host
         qry.event_url = url
         qry.source = source
         qry.price = price
         if category is not None:
             qry.category = category
         results = Attendings.query(Attendings.event_id == qry.get_by_id(e_id))
         if results is not None:
             qry.attendees = attendees + results.count()
         else:
             qry.attendees = attendees
         qry.put()
Example #12
0
    def attend(u_key, e_key):
        event1 = Event()
        attendings1 = Attendings()

        qry = User.get_by_id(u_key)
        logging.info("query is : {}".format(qry))
        if qry is None:
            return 1
        else:
            attendings1.user_id = u_key
        if Event.get_by_id(e_key) is None:
            return 2
        else:
            attendings1.event_id = e_key
        if attendings1.check_attend_exist(u_key, e_key) is False:
            attendings1.put()
            event1.update_attendees(e_key, action="add")
        return 0