예제 #1
0
def post_month_views(request):

    context = initialize_context(request)
    token = get_token(request)

    notebooks = collect_onenote_notebooks(token)
    notebook_id = find_notebook_id(notebooks, PLANNER_NOTEBOOK_DISPLAYNAME)
    sections = collect_notebook_sections(token, notebook_id)
    for num in range(len(MONTHS)):
        month_name = MONTHS[num]
        section_id = find_section_id(sections, month_name)

        page_fname = "./onenote_planner/images/pages/months/month-{:02d}.html".format(
            num + 1)
        calendar_image = "./onenote_planner/images/pages/months/tex/month-{:02d}.png".format(
            num + 1)
        budget_image = "./onenote_planner/images/templates/months/budget.png"

        files = {
            "Presentation": (None, open(page_fname, "rb"), "text/html"),
            "calendar": (None, open(calendar_image, "rb"), "image/png"),
            "budget": (None, open(budget_image, "rb"), "image/png")
        }
        output = create_new_page(token, section_id, fdict=files)

    return HttpResponse(output)
예제 #2
0
def open_planner(request):

    context = initialize_context(request)

    token = get_token(request)

    return render(request, 'onenote_planner/makeplanner.html', context)
예제 #3
0
def post_week_views(request):

    context = initialize_context(request)
    token = get_token(request)

    notebooks = collect_onenote_notebooks(token)
    notebook_id = find_notebook_id(notebooks, PLANNER_NOTEBOOK_DISPLAYNAME)
    sections = collect_notebook_sections(token, notebook_id)

    for num in range(len(MONTHS)):
        month_name = MONTHS[num]
        section_id = find_section_id(sections, month_name)
        file_list = glob.glob(
            "./onenote_planner/images/pages/weeks/*date_{:02d}*".format(num +
                                                                        1))

        for file_name in file_list:
            week_filename = file_name.split("/")[-1]
            week_no = week_filename.split("_")[1]
            week_file_name = "./onenote_planner/images/pages/weeks/tex/week-{0}.png".format(
                week_no)
            files = {
                "Presentation": (None, open(file_name, "rb"), "text/html"),
                "week": (None, open(week_file_name, "rb"), "image/png")
            }

            output = create_new_page(token, section_id, fdict=files)

    return HttpResponse(output)
예제 #4
0
def mailtoBC(request):
    print('this is in mailtoBC function')
    # new event to B
    global global_var
    global old_event
    context = initialize_context(request)
    token = get_token(request)

    time_choice = global_var['findmeetingtime']['old_event_time'][
        'start'] + ' - ' + global_var['findmeetingtime']['old_event_time'][
            'end']

    request.session['timeChoice'] = time_choice
    print('time choice:', time_choice)
    global_var['findmeetingtime']['timeChoice'] = time_choice

    status_code = create_and_sendEmailto_B(request, token)
    context['status_code_B'] = status_code

    # old event to C
    request.session['old_event'] = old_event
    status_code = create_and_sendEmailto_C(request, token)
    context['status_code_C'] = status_code

    return render(request, 'tutorial/mail.html', context)
예제 #5
0
def one_drive(request):
    context = initialize_context(request)

    token = get_token(request)

    files = get_one_drive_items(token)

    for file in files['value']:
        file['DownloadUrl'] = file['@microsoft.graph.downloadUrl']
        file['CreationDay'] = datetime.datetime.strptime(
            file['createdDateTime'], '%Y-%m-%dT%H:%M:%S.%fZ').date()
        file['CreationWeek'] = str(
            file['CreationDay'].isocalendar()[1]) + '-' + str(
                file['CreationDay'].year)

    # sum all items by calendar week
    items_df = pd.DataFrame.from_dict(files['value'])
    items_df = items_df.groupby(by="CreationWeek", dropna=False).count()
    items_df.rename(columns={'createdDateTime': 'count'}, inplace=True)

    # define new figure with plotly
    fig = px.bar(x=items_df.index.tolist(),
                 y=items_df['count'].tolist(),
                 labels=dict(x="Calendar Week",
                             y="Number of umploaded pictures"))

    # graph plot
    plt_div = plot(fig, output_type='div')

    # define context
    context['files'] = files['value']
    context['plot_div'] = plt_div

    return render(request, 'tutorial/one_drive.html', context)
예제 #6
0
def get_notebook_pages(request, name=PLANNER_NOTEBOOK_DISPLAYNAME):

    name = "Research Fracture"
    context = initialize_context(request)
    token = get_token(request)

    notebooks = collect_onenote_notebooks(token)
    notebook_id = find_notebook_id(notebooks, name)

    sections = collect_notebook_sections(token, notebook_id)['value']

    all_pages = []
    for section in sections:
        print(section)
        section_id = section['id']
        pages = collect_notebook_pages(token, section_id)
        all_pages.append(pages)

    print(all_pages)

    first_pages_set = all_pages[0]['value']
    first_page_id = first_pages_set[0]['id']
    content = get_page_content(token, first_page_id)

    context['errors'] = content

    print(str(content))
    return render(request, "tutorial/home.html", context)
예제 #7
0
def calendar(request):
    context = initialize_context(request)

    token = get_token(request)

    events = get_calendar_events(token)

    cal_obj = cal.Calendar(firstweekday=6)

    if events:
        # Convert the ISO 8601 date times to a datetime object
        # This allows the Django template to format the value nicely
        for event in events['value']:
            event['start']['dateTime'] = dateutil.parser.parse(
                event['start']['dateTime'])
            event['end']['dateTime'] = dateutil.parser.parse(
                event['end']['dateTime'])

        window = events['value'][0]['start']['dateTime']

        context['events'] = events['value']
        context['month'] = window.strftime("%B")

        context['weeks'] = list()
        for week in cal_obj.monthdatescalendar(window.year, window.month):
            weekdays = list()
            for day in week:
                matches = [
                    x for x in context['events']
                    if x['start']['dateTime'].day == day.day
                ]
                weekdays.append({"day": day, "events": matches})
            context['weeks'].append(weekdays)

    return render(request, 'tutorial/calendar.html', context)
예제 #8
0
def inbox(request):
    context = initialize_context(request)
    email = context['user']['email']
    token = get_token(request)
    data = get_inbox_mailfolder_data(token)
    inbox = list()

    if data:
        for item in data['value']:
            temp_dict = {}
            temp_dict = {
                'sender':
                item['sender']['emailAddress']['address'],
                'recipients':
                [m['emailAddress']['address'] for m in item['toRecipients']],
                'subject':
                item['subject'],
                'body':
                item['bodyPreview'],
                'created':
                item['createdDateTime']
            }
            inbox.append(temp_dict)

    context['inbox'] = inbox

    return render(request, 'tutorial/inbox.html', context)
예제 #9
0
def userinfo(request):
    context = initialize_context(request)
    token = get_token(request)
    print('TOKEN', token)
    user = get_user(token)
    #print(context['user'])

    return render(request, 'tutorial/userinfo.html', context)
예제 #10
0
def post_notebook(request):
    print("Posting Notebook...")

    context = initialize_context(request)
    token = get_token(request)

    output = create_new_notebook(token)

    return HttpResponse(output)
예제 #11
0
def schedule_getfreeorbusy(request):
    context = initialize_context(request)
    token = get_token(request)

    events = post_freeorbusy(token)
    context['errors'] = [{'message': 'Events', 'debug': format(events)}]

    get_ggevents()
    return render(request, 'tutorial/schedule.html', context)
예제 #12
0
def inviteeC_handle(request):

    global global_var
    global old_event
    context = initialize_context(request)
    token = get_token(request)

    request.session['findmeetingtime'] = old_event
    print('this is in inviteeC handle')
    # create_and_addEvent(request, token)
    accept = request.GET['accept']
    # print('the accept of invitee is ', accept)
    if accept == '1':
        #invitee accept the request
        print("the invitee has accepted the request")
        print('old event id: ', old_event['eventid'])
        # delete the old event need event id old_event['eventid']
        delete_status = delete_event(old_event['eventid'], token)

        if delete_status == 204:
            # delete successfully and create event
            reply = create_and_addEvent_byinvitee(request, token)
            if reply.status_code == 200 or reply.status_code == 201 or reply.status_code == 202:
                print(
                    "the event has been created and added to Outlook. Request has been sent."
                )
                reply_json = reply.json()

                event = {
                    'event_id': reply_json['id'],
                    'extension_name':
                    reply_json['extensions'][0]['extensionName']
                }

                global_var['eventinfo'].append(event)

                # getEvent_and_extension(request, token)
                context[
                    'page_info'] = 'You have accepted the time slot of meeting. Meeting request mail has been sent to your email.'
            else:
                print(
                    "there may be some error happened when creating event. status code: ",
                    reply.status_code)
        else:
            print('deleting old event failed')

    elif accept == '0':
        # invitee reject the request, delete B if B exist
        print("the invitee has rejected the request")

        context['page_info'] = 'You have rejected the time slot of meeting'

    else:
        print("something wrong happened in accept.")

    return render(request, 'tutorial/invitee.html', context)
예제 #13
0
def directory_contents(request):
    context = initialize_context(request)

    token = get_token(request)

    events = get_directory_contents(token)

    print(events)

    return render(request, 'tutorial/directory_contents.html', events)
예제 #14
0
def calendar_p(request):
    context = initialize_context(request)

    token = get_token(request)

    events = get_calendar_events(token)

    context['errors'] = [{'message': 'Events', 'debug': format(events)}]

    return render(request, 'tutorial/home.html', context)
예제 #15
0
def calendar(request):
  context = initialize_context(request)

  token = get_token(request)

  events = get_calendar_events(token)

  context['errors'] = [
    { 'message': 'Events', 'debug': format(events)}
  ]
예제 #16
0
파일: views.py 프로젝트: VladilenK/samples
def msteams(request):
    context = initialize_context(request)

    token = get_token(request)

    teams = get_teams(token)

    if teams:
        context['teams'] = teams['value']

    return render(request, 'tutorial/teams.html', context)
예제 #17
0
파일: views.py 프로젝트: VladilenK/samples
def sharepoint(request):
    context = initialize_context(request)

    token = get_token(request)

    sites = get_sharepoint_sites(token)

    if sites:
        context['sites'] = sites['value']

    return render(request, 'tutorial/sharepoint.html', context)
예제 #18
0
def post_given_month_all_pages(request, month_number):

    context = initialize_context(request)
    token = get_token(request)

    notebooks = collect_onenote_notebooks(token)
    notebook_id = find_notebook_id(notebooks, PLANNER_NOTEBOOK_DISPLAYNAME)

    all_outputs = post_all_month(token, notebook_id, month_number)

    return render(request, "onenote_planner/makeplanner.html", context)
예제 #19
0
파일: views.py 프로젝트: VladilenK/samples
def site_details(request, id):
    context = initialize_context(request)
    token = get_token(request)
    # firstComma = id.find(',')
    # secondComma = id.find(',')
    siteId = id.split(",")[1]
    site = get_sharepoint_site(token, siteId)
    if site:
        context['site'] = site

    return render(request, 'tutorial/site_details.html', context)
예제 #20
0
def onedrive_details(request):
    context = initialize_context(request)

    token = get_token(request)

    events = get_onedrive_details(token)

    context['events'] = events['owner']['user']

    print(context)

    return render(request, 'tutorial/onedrive_details.html', context)
예제 #21
0
def get_notebooks(request):

    print("Requesting Notebooks...")

    context = initialize_context(request)

    token = get_token(request)

    notebooks = collect_onenote_notebooks(token)

    print(notebooks)

    return render(request, "onenote_planner/makeplanner.html", context)
예제 #22
0
def onedrive_directory(request):
    context = initialize_context(request)

    token = get_token(request)

    events = get_onedrive_directory(token)

    context['events'] = events['value']

    for e in events['value']:
        print(e['name'])

    return render(request, 'tutorial/onedrive_directory.html', context)
예제 #23
0
def get_notebook_sections(request, name=PLANNER_NOTEBOOK_DISPLAYNAME):

    context = initialize_context(request)
    token = get_token(request)

    notebooks = collect_onenote_notebooks(token)
    notebook_id = find_notebook_id(notebooks, name)

    sections = collect_notebook_sections(token, notebook_id)

    print(sections)

    context['errors'] = sections
    return render(request, "onenote_planner/makeplanner.html", context)
예제 #24
0
def mail(request):

    global global_var
    context = initialize_context(request)
    token = get_token(request)

    time_choice = request.POST['timeChoice']
    request.session['timeChoice'] = time_choice
    print('time choice:', time_choice)
    global_var['findmeetingtime']['timeChoice'] = time_choice
    status_code = create_and_sendEmail(request, token)
    context['status_code'] = status_code

    return render(request, 'tutorial/mail.html', context)
def usuario_dato(request):
    context = initialize_context(request)
    print("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF")
    print(context)
    token = get_token(request)
    users = get_user_dato(token)
    print("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF")
    print(users)
    if users:
        context['users'] = users.items()

    print("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF")
    print(context)
    return render(request, 'tutorial/usuario_dato.html', context)
def usuario_lista(request):
    context = initialize_context(request)

    token = get_token(request)

    users = get_user_list(token)
    print(users)
    if users:
        #context['users'] = users['displayName']
        context['users'] = users
    print(
        "///////////////////////////////////////////////////////////////////////"
    )
    print(context)
    return render(request, 'tutorial/usuario_lista.html', context)
예제 #27
0
def calendar(request):
  context = initialize_context(request)

  token = get_token(request)

  events = get_calendar_events(token)

  if events:
    # Convert the ISO 8601 date times to a datetime object
    # This allows the Django template to format the value nicely
    for event in events['value']:
      event['start']['dateTime'] = dateutil.parser.parse(event['start']['dateTime'])
      event['end']['dateTime'] = dateutil.parser.parse(event['end']['dateTime'])

    context['events'] = events['value']

  return render(request, 'tutorial/calendar.html', context)
예제 #28
0
def calendar(request):
    context = initialize_context(request)

    token = get_token(request)

    events = get_calendar_events(token)

    if events:
        for event in events['value']:
            event['start']['dateTime'] = dateutil.parser.parse(
                event['start']['dateTime'])
            event['end']['dateTime'] = dateutil.parser.parse(
                event['end']['dateTime'])

        context['events'] = events['value']

    return render(request, 'tutorial/calendar.html', context)
예제 #29
0
def post_month_sections(request):

    context = initialize_context(request)
    token = get_token(request)

    notebooks = collect_onenote_notebooks(token)

    notebook_id = find_notebook_id(notebooks, PLANNER_NOTEBOOK_DISPLAYNAME)

    output_lst = []
    for month in MONTHS:
        output_lst.append(
            create_new_notebook_section(token, notebook_id,
                                        section_name=month))

    context['errors'] = output_lst

    return HttpResponse(output_lst)
예제 #30
0
def post_notebook_section(request):

    print("Posting notebook section...")

    context = initialize_context(request)
    token = get_token(request)

    notebooks = collect_onenote_notebooks(token)

    notebook_id = find_notebook_id(notebooks, PLANNER_NOTEBOOK_DISPLAYNAME)

    output = create_new_notebook_section(token, notebook_id)

    print(output)
    context['errors'] = output

    #return render(request, "tutorial/home.html", context)
    return HttpResponse(output)