Esempio n. 1
0
def agenda_edit(request, meeting_id):
    group = get_current_group(request)
    if group == None:
        return HttpResponseRedirect(reverse('index'))

    meeting = Meeting.objects.get(pk=int(meeting_id))
    if meeting.group != group:
        return HttpResponseRedirect(reverse('index'))

    doc_type = 'agenda'
    request_type = 'refresh'
    task_list_headings = ('Description', 'Assigned to', 'Deadline')
    items = meeting.item_set.filter(group=group).order_by('item_no')
    overdue_tasks_list = get_overdue_tasks_list(group=group,
                                                meeting=meeting,
                                                doc_type=doc_type)
    pending_tasks_list = get_outstanding_tasks_list(group=group,
                                                    meeting=meeting,
                                                    doc_type=doc_type)
    completed_tasks_list = get_completed_tasks_list(group=group,
                                                    meeting=meeting,
                                                    doc_type=doc_type)

    if request.method == "POST" and 'ajax_button' in request.POST:
        request_type = 'ajax'
        if request.POST['ajax_button'] != 'page_refresh':
            save_formlist(request, group, items, 'items', doc_type)
            meeting_form = save_meeting_form(request, group, meeting, doc_type)
        if request.POST['ajax_button'] == 'add_item':
            add_item(group, meeting, items, doc_type)
        if request.POST['ajax_button'][0:11] == 'delete_item':
            delete_item(request, group, meeting)
        if request.POST['ajax_button'] == 'move_item':
            move_item(request, group, meeting)
        items = meeting.item_set.filter(group=group).order_by('item_no')

    item_formlist = build_formlist(group, items, 'items', doc_type)

    meeting_form = AgendaMeetingForm(group=group,
                                     instance=meeting,
                                     label_suffix='')
    meeting_duration = get_formatted_meeting_duration(meeting_id)
    meeting_end_time = calculate_meeting_end_time(meeting)

    templates = get_templates(request_type, doc_type)
    responses = []
    menu = {
        'parent': 'meetings',
        'child': 'current_meetings',
        'tips': 'create_agenda'
    }
    for template in templates:
        part_response = render(
            request, template, {
                'menu': menu,
                'completed_tasks_list': completed_tasks_list,
                'doc_type': doc_type,
                'group': group,
                'item_formlist': item_formlist,
                'items': items,
                'meeting': meeting,
                'meeting_duration': meeting_duration,
                'meeting_end_time': meeting_end_time,
                'meeting_form': meeting_form,
                'meeting_id': meeting_id,
                'overdue_tasks_list': overdue_tasks_list,
                'pending_tasks_list': pending_tasks_list,
                'task_list_headings': task_list_headings,
            })
        responses.append(part_response)
    response = get_response(responses, request_type)

    return response
Esempio n. 2
0
def agenda_edit(request, meeting_id):
    group = get_current_group(request)
    if group == None:	
        return HttpResponseRedirect(reverse('index'))
        
    meeting = Meeting.objects.get(pk=int(meeting_id))
    if meeting.group != group:
        return HttpResponseRedirect(reverse('index'))

    doc_type = 'agenda'
    request_type = 'refresh'
    task_list_headings = ('Description',
                          'Assigned to',
                          'Deadline')
    items = meeting.item_set.filter(group=group).order_by('item_no')
    overdue_tasks_list = get_overdue_tasks_list(group=group,
                                                meeting=meeting,
                                                doc_type=doc_type)
    pending_tasks_list = get_outstanding_tasks_list(group=group,
                                                    meeting=meeting,
                                                    doc_type=doc_type)
    completed_tasks_list = get_completed_tasks_list(group=group,
                                                    meeting=meeting,
                                                    doc_type=doc_type)

    if request.method == "POST" and 'ajax_button' in request.POST:
        request_type = 'ajax'
        if request.POST['ajax_button'] != 'page_refresh':              
            save_formlist(request, group, items, 'items', doc_type)
            meeting_form = save_meeting_form(request, group, meeting, doc_type)            
        if request.POST['ajax_button']=='add_item':
            add_item(group, meeting, items, doc_type)
        if request.POST['ajax_button'][0:11] =='delete_item':
            delete_item(request, group, meeting)
        if request.POST['ajax_button'] == 'move_item':
            move_item(request, group, meeting)                          
        items = meeting.item_set.filter(group=group).order_by('item_no')

    item_formlist = build_formlist(group, items, 'items', doc_type)
    
    meeting_form = AgendaMeetingForm(group=group, instance=meeting,
                                     label_suffix='')
    meeting_duration = get_formatted_meeting_duration(meeting_id)
    meeting_end_time = calculate_meeting_end_time(meeting)
    
    templates = get_templates(request_type, doc_type)
    responses = []
    menu = {'parent': 'meetings',
            'child': 'current_meetings',
            'tips': 'create_agenda'}
    for template in templates:
        part_response = render(request, template, {
                               'menu': menu,
                               'completed_tasks_list': completed_tasks_list,
                               'doc_type': doc_type,
                               'group': group,
                               'item_formlist': item_formlist,
                               'items': items,
                               'meeting': meeting,
                               'meeting_duration': meeting_duration,
                               'meeting_end_time': meeting_end_time,
                               'meeting_form': meeting_form,
                               'meeting_id': meeting_id,                      
                               'overdue_tasks_list': overdue_tasks_list,
                               'pending_tasks_list': pending_tasks_list,
                               'task_list_headings': task_list_headings,
                               })
        responses.append(part_response)
    response = get_response(responses, request_type)
    
    return response
Esempio n. 3
0
def minutes_edit(request, meeting_id):
    group = get_current_group(request)
    if group == None:
        return HttpResponseRedirect(reverse('index'))

    meeting = Meeting.objects.get(pk=int(meeting_id))
    if meeting.group != group:
        return HttpResponseRedirect(reverse('index'))

    doc_type = 'minutes'
    request_type = 'refresh'

    decisions = meeting.decision_set.filter(group=group).\
                order_by('item', 'decision_no')
    items = meeting.item_set.filter(group=group).order_by('item_no')
    tasks = meeting.task_set.filter(group=group).\
            order_by('item', 'task_no')

    completed_tasks_list = get_completed_tasks_list(group=group,
                                                    meeting=meeting,
                                                    doc_type='minutes')
    incomplete_tasks_list = Task.lists.incomplete_tasks().filter(group=group)
    new_tasks = Task.lists.incomplete_tasks().filter(group=group,
                                                     meeting=meeting)

    if request.method == "POST" and 'ajax_button' in request.POST:
        request_type = 'ajax'
        # before changing any data, save everything
        if request.POST['ajax_button'] != 'page_refresh':
            save_formlist(request, group, decisions, 'decisions', doc_type)
            save_formlist(request, group, items, 'items', doc_type)
            save_formlist(request, group, tasks, 'tasks', doc_type)
            save_meeting_form(request, group, meeting, doc_type)
            save_next_meeting_form(request, group, meeting)
        # now change what needs to be changed
        if request.POST['ajax_button'] == 'clear_minutes':
            clear_minutes(request, group, meeting, decisions, items, tasks)
        if request.POST['ajax_button'][:12] == 'add_decision':
            add_decision(request, group, meeting)
        if request.POST['ajax_button'] == 'add_item':
            add_item(group, meeting, items, 'minutes')
        if request.POST['ajax_button'][:8] == 'add_task':
            add_task(request, group, meeting)
        if request.POST['ajax_button'][:15] == 'delete_decision':
            delete_decision(request, group, meeting)
        if request.POST['ajax_button'][:11] == 'delete_item':
            delete_item(request, group, meeting)
        if request.POST['ajax_button'][:11] == 'delete_task':
            delete_task(request, group, meeting)

        decisions = meeting.decision_set.filter(group=group).\
                    order_by('item', 'decision_no')
        items = meeting.item_set.filter(group=group).order_by('item_no')
        tasks = meeting.task_set.filter(group=group).\
                order_by('item', 'task_no')

    decision_formlist = build_formlist(group, decisions, 'decisions',
                                       'minutes')
    item_formlist = build_formlist(group, items, 'items', 'minutes')
    task_formlist = build_formlist(group, tasks, 'tasks', 'minutes')

    item_count = items.count()
    meeting_duration = get_formatted_meeting_duration(meeting)
    meeting_end_time = calculate_meeting_end_time(meeting)
    meeting_form = MinutesMeetingForm(group, instance=meeting, label_suffix='')
    next_meeting_form = NextMeetingForm(group,
                                        instance=meeting,
                                        label_suffix='')
    templates = get_templates(request_type, 'minutes')
    responses = []
    menu = {
        'parent': 'meetings',
        'child': 'current_meetings',
        'tips': 'create_minutes'
    }
    for template in templates:
        response = render(
            request, template, {
                'menu': menu,
                'doc_type': doc_type,
                'meeting_id': meeting_id,
                'meeting': meeting,
                'meeting_duration': meeting_duration,
                'meeting_end_time': meeting_end_time,
                'completed_tasks_list': completed_tasks_list,
                'incomplete_tasks_list': incomplete_tasks_list,
                'meeting_form': meeting_form,
                'next_meeting_form': next_meeting_form,
                'item_formlist': item_formlist,
                'task_formlist': task_formlist,
                'decision_formlist': decision_formlist,
                'decisions': decisions,
                'tasks': tasks,
            })
        responses.append(response)
    response = get_response(responses, request_type)

    return response
Esempio n. 4
0
def minutes_edit(request, meeting_id):
    group = get_current_group(request)
    if group == None:	
        return HttpResponseRedirect(reverse('index'))
        
    meeting = Meeting.objects.get(pk=int(meeting_id))
    if meeting.group != group:
        return HttpResponseRedirect(reverse('index'))
    
    doc_type = 'minutes'
    request_type = 'refresh'
  
    decisions = meeting.decision_set.filter(group=group).\
                order_by('item', 'decision_no')
    items = meeting.item_set.filter(group=group).order_by('item_no')
    tasks = meeting.task_set.filter(group=group).\
            order_by('item', 'task_no')
    
    completed_tasks_list = get_completed_tasks_list(group=group,
                                                    meeting=meeting,
                                                    doc_type='minutes')
    incomplete_tasks_list = Task.lists.incomplete_tasks().filter(group=group)
    new_tasks = Task.lists.incomplete_tasks().filter(group=group,
                                                     meeting=meeting)	

    if request.method == "POST" and 'ajax_button' in request.POST:
        request_type = 'ajax'
        # before changing any data, save everything
        if request.POST['ajax_button'] != 'page_refresh':              
            save_formlist(request, group, decisions, 'decisions', doc_type)
            save_formlist(request, group, items, 'items', doc_type)
            save_formlist(request, group, tasks, 'tasks', doc_type)
            save_meeting_form(request, group, meeting, doc_type)
            save_next_meeting_form(request, group, meeting)
        # now change what needs to be changed
        if request.POST['ajax_button']=='clear_minutes':
            clear_minutes(request, group, meeting, decisions, items, tasks)
        if request.POST['ajax_button'][:12]=='add_decision':
            add_decision(request, group, meeting)
        if request.POST['ajax_button']=='add_item':
            add_item(group, meeting, items, 'minutes')
        if request.POST['ajax_button'][:8]=='add_task':
            add_task(request, group, meeting)
        if request.POST['ajax_button'][:15]=='delete_decision':
            delete_decision(request, group, meeting)
        if request.POST['ajax_button'][:11]=='delete_item':
            delete_item(request, group, meeting)            
        if request.POST['ajax_button'][:11]=='delete_task':
            delete_task(request, group, meeting)

        decisions = meeting.decision_set.filter(group=group).\
                    order_by('item', 'decision_no')
        items = meeting.item_set.filter(group=group).order_by('item_no')
        tasks = meeting.task_set.filter(group=group).\
                order_by('item', 'task_no')
   
    decision_formlist = build_formlist(group, decisions, 'decisions',
                                       'minutes')
    item_formlist = build_formlist(group, items, 'items', 'minutes')
    task_formlist = build_formlist(group, tasks, 'tasks', 'minutes')
        
    item_count = items.count()
    meeting_duration = get_formatted_meeting_duration(meeting)
    meeting_end_time = calculate_meeting_end_time(meeting)
    meeting_form = MinutesMeetingForm(group, instance=meeting, label_suffix='') 
    next_meeting_form = NextMeetingForm(group, instance=meeting,
                                        label_suffix='')
    templates = get_templates(request_type, 'minutes')
    responses = []
    menu = {'parent': 'meetings',
            'child': 'current_meetings',
            'tips': 'create_minutes'}
    for template in templates:
        response = render(request, template, {
                          'menu': menu,
                          'doc_type': doc_type,
                          'meeting_id': meeting_id,
                          'meeting': meeting,
                          'meeting_duration': meeting_duration,
                          'meeting_end_time': meeting_end_time,
                          'completed_tasks_list': completed_tasks_list,
                          'incomplete_tasks_list': incomplete_tasks_list,
                          'meeting_form': meeting_form,
                          'next_meeting_form': next_meeting_form,
                          'item_formlist': item_formlist,
                          'task_formlist': task_formlist,
                          'decision_formlist': decision_formlist,
                          'decisions': decisions,
                          'tasks': tasks,
                          })
        responses.append(response)
    response = get_response(responses, request_type)
    
    return response