Exemplo n.º 1
0
def event_calendar_list(request):
	if not mf_app.isLoggedIn():
		# TODO: add notification
		return -1
	userId = session["id"]
	
	calendarId = request.args.get("calendar_id", None)
	
	if calendarId is None:
		# TODO: add notification
		return -1
	
	events = mf_database.getEventsOfCalenderOfUser(userId, calendarId)
	if events == -1:
		# TODO: add notification
		return -1
	
	formattedEvents = [{
			"id": e["id"],
			"calendar_id": calendarId,
			"name": e["name"],
			"start": str(e["start"]),
			"end": str(e["end"]),
		} for e in events]
	
	return formattedEvents
Exemplo n.º 2
0
def getEvent(eventId):
    if not isLoggedIn():
        return -1
    userId = session["id"]

    # return list of event objects. "start" and "end" is optional
    cursor = getCursor()
    try:
        sql = "select eventn.EventId, eventn.`Name`, eventn.`Start`, eventn.`End`, eventcalendar.CalendarId " \
         "from `user` " \
         "join usercalendars on usercalendars.UserId = `user`.UserId " \
         "join eventcalendar on eventcalendar.CalendarId = usercalendars.CalendarId " \
         "join eventn on eventn.EventId = eventcalendar.EventId " \
         "where `user`.UserId = %s and eventn.EventId = %s"
        cursor.execute(sql, (
            userId,
            eventId,
        ))
        result = cursor.fetchall()
        if len(result) != 1:
            return -1
        event = {
            "id": result[0][0],
            "name": result[0][1],
            "start": result[0][2],
            "end": result[0][3],
            "calendarId": result[0][4],
        }
        return event
    except mysql.connector.Error as err:
        printError(err)
        return -1
    finally:
        cursor.close()
Exemplo n.º 3
0
def loggout(request):
	if not mf_app.isLoggedIn():
		return -1
	username = session["username"]
	
	return {
		"success": True,
		"data": {
			'username': username
		}
	}
Exemplo n.º 4
0
def task_list(request):
	if not mf_app.isLoggedIn():
		return -1
	userId = session["id"]

	tasks = mf_database.getTasksOfUser(userId)
	if tasks == -1:
		# TODO: add notification stuff
		return -1

	return [{
		  "id": t["id"],
		  "name": t["name"]
						  } for t in tasks if t["parentId"] == None]
Exemplo n.º 5
0
def calendar_list(request):
	if not mf_app.isLoggedIn():
		return -1
	userId = session["id"]
	
	calendars = mf_database.getAllCalendarsOfUser(userId)
	if calendars == -1:
		# TODO: add notification stuff
		return -1
	
	return [{
		  "id": c["id"],
		  "name": c["name"],
		  "rights": c["adminLevel"], # rename
		  "public": c["public"]
						  } for c in calendars]
Exemplo n.º 6
0
def task_edit(request):
	if not mf_app.isLoggedIn():
		return -1

	taskId = request.args.get("id", None)
	if taskId is None:
		# TODO: add notification
		return -1

	taskObject = mf_database.getTask(taskId)
	if taskObject == -1:
		# TODO: add notification stuff
		return -1

	taskObject["calendars"] = calendar_list(request)

	return taskObject
Exemplo n.º 7
0
def calendar_edit(request):
	if not mf_app.isLoggedIn():
		# TODO: add notification
		return -1
	userId = session["id"]
	
	calendarId = request.args.get("id", None)
	
	if calendarId is None:
		# TODO: add notification
		return -1
	
	calendar = mf_database.getCalendarOfUser(userId, calendarId)
	
	if calendar == -1:
		# TODO: add notification
		return -1
	
	return {
		"id": calendar["id"],
		"name": calendar["name"],
		"public": calendar["public"],
	}
Exemplo n.º 8
0
def nav(request):
	if mf_app.isLoggedIn():
		return {
					"items":
					[
						{
							"title": "Home",
							"isparent": 0,
							"link": "home",
							"children": []
						},{
							"title": "Calendar",
							"isparent": 1,
							"link": "calendar",
							"children": [
								{
									"title": "New Calendar",
									"isparent": 0,
									"link": "calendar/new",
									"children": []
								},{
									"title": "My Calendars",
									"isparent": 0,
									"link": "calendar/list",
									"children": []
								}
							]
						},{
							"title": "Event",
							"isparent": 1,
							"link": "/event",
							"children": [
								{
									"title": "New Event",
									"isparent": 0,
									"link": "event/new",
									"children": []
								},{
									"title": "My Events",
									"isparent": 0,
									"link": "event/list",
									"children": []
								}
							]
						},{
							"title": "Tasks",
							"isparent": 1,
							"link": "/task",
							"children": [
								{
									"title": "New Task",
									"isparent": 0,
									"link": "task/new",
									"children": []
								},{
									"title": "My Tasks",
									"isparent": 0,
									"link": "task/list",
									"children": []
								}
							]
						},{
							"title": "Loggout",
							"isparent": 0,
							"link": "/loggedout",
							"children": []
						}
					]
			}
	else:
		return frontmenu(request)