def createUser(name, facebookId, accessToken, pictureURL):
     user = User(name, facebookId, accessToken, pictureURL)
     user = user.save()
     
     print "created user:", user.id 
     
     CalendarController.createCalendar(user.id) #creates a calendar for this user
     
     return user.id
Ejemplo n.º 2
0
    def createUser(name, facebookId, accessToken, pictureURL):
        user = User(name, facebookId, accessToken, pictureURL)
        user = user.save()

        print "created user:", user.id

        CalendarController.createCalendar(
            user.id)  #creates a calendar for this user

        return user.id
Ejemplo n.º 3
0
 def createEvent(user_id, name, description, latitude, longitude, date, start_time, end_time, tags, is_private, invite_list): #invite_list is currently facebook IDs
     print "Before casting"
     try:
         user_id = ObjectId(user_id)
         if invite_list[0] == "" or invite_list == "\"\"":
             invite_list = list()
     except:
         print "A user could not be cast to an ObjectId"
         return "fail"
     print "All successfully casted"
     
     client = MongoClient(System.URI)
     db = client.ConnectMe
     users = db.user
     
     our_users = users.find({"facebookId":  {"$in" : invite_list}}) #gets users to invite, based on the provided facebook IDs
     
     ids = list()
     for user in our_users:
         ids.append(user['_id'])
     
     attending_list = list()
     attending_list.append(user_id)#add the event creator to the attending list
     event = Event(user_id=user_id, name=name, description=description, latitude=latitude, longitude=longitude, date=date, start_time=start_time, end_time=end_time, tags=tags, is_private=is_private, invite_list=ids, attending_list=attending_list)
     new_event = event.save()#create the event
     event_id = new_event.id
     print "Event", new_event.id, "created by user", user_id
     for invitee in ids:
         EventController.sendInvite(event_id, invitee) #invite each of the users to the event
     result = CalendarController.addEvent(str(event_id), str(user_id))#add this event to the creator's calendar
     return result
Ejemplo n.º 4
0
 def joinEvent(user_id, event_id):
     try:
         user_id = ObjectId(user_id)
         event_id = ObjectId(event_id)
     except:
         print "Invalid object id"
         return "fail"
     
     print event_id
     
     client = MongoClient(System.URI)
     db = client.ConnectMe
     events = db.event
     
     event = events.find_one({"_id" : event_id}) #get the full event object
     if not event:
         print "event not found"
         return "fail"
     
     if user_id in event['invite_list']: #remove from the invite list if the user was invited
         event['invite_list'].remove(user_id)
     if user_id not in event['attending_list']: #add the user to the attending list
         event['attending_list'].append(user_id)
     events.save(event)
     print "User", user_id, "added to event", event_id
     result = CalendarController.addEvent(str(event_id), str(user_id)) #add the event to the user's calendar
     return result
Ejemplo n.º 5
0
def getAttendingEvents(request):
    attendingEvents = CalendarController.getAttendingEvents(
        request.GET['user_id'])
    if not attendingEvents or attendingEvents == "fail":
        return HttpResponse("Fail", status=401)
    else:
        return HttpResponse(attendingEvents)
Ejemplo n.º 6
0
 def leaveEvent(user_id, event_id):
     try:
         user_id = ObjectId(user_id)
         event_id = ObjectId(event_id)
     except:
         return "fail"
     
     client = MongoClient(System.URI)
     db = client.ConnectMe
     events = db.event
     
     event = events.find_one({"_id" : event_id}) #get the full event object
     
     if user_id in event['attending_list']:
         event['attending_list'].remove(user_id) #remove the user from the event's attending list
     events.save(event)
     print "User", user_id, "left event", event_id
     CalendarController.removeEvent(str(event_id), str(user_id)) #remove the event from the user's calendar
Ejemplo n.º 7
0
 def deleteEvent(event_id):
     try:
         event_id = ObjectId(event_id)
     except:
         return "fail"
     client = MongoClient(System.URI)
     db = client.ConnectMe
     events = db.event
     
     event = events.find_one({"_id": event_id}) #get the full event
     for user in event['invite_list']:
         CalendarController.removeEvent(str(event_id), str(user)) #remove event from each user's calendar
     for user in event['attending_list']:
         CalendarController.removeEvent(str(event_id), str(user)) #remove event from each user's calendar
     CalendarController.removeEvent(str(event_id), str(event['user_id'])) #remove event from the creator's calendar
     events.remove({"_id": event_id}) #remove from the database
     print "Deleted event", event_id
Ejemplo n.º 8
0
def getInvitedEvents(request):
    invitedEvents = CalendarController.getInvitedEvents(request.GET['user_id'])
    if not invitedEvents or invitedEvents == "fail":
        return HttpResponse("Fail", status=401)
    else:
        return HttpResponse(invitedEvents)
Ejemplo n.º 9
0
def getAttendingEvents(request):
    attendingEvents = CalendarController.getAttendingEvents(request.GET['user_id'])
    if not attendingEvents or attendingEvents == "fail":
        return HttpResponse("Fail", status=401)
    else:
        return HttpResponse(attendingEvents)
Ejemplo n.º 10
0
 def sendInvite(event_id, user_id):
     result = CalendarController.addEvent(event_id, user_id, True)#add an "invite" event to the friend's calendar
     return result
Ejemplo n.º 11
0
def getInvitedEvents(request):
    invitedEvents = CalendarController.getInvitedEvents(request.GET['user_id'])
    if not invitedEvents or invitedEvents == "fail":
        return HttpResponse("Fail", status=401)
    else:
        return HttpResponse(invitedEvents)
Ejemplo n.º 12
0
 def create_calendar_window(self):
     calendar_controller = CalendarController(self.root)