Exemplo n.º 1
0
def category_schedule_list(request):
    categories = TaskCategory.objects.filter(active=True)
    context = {'categories': SortedDict.fromkeys(categories, [])}
    for category in context['categories']:
        context['categories'][category] = TaskTemplate.objects.filter(
            category=category)
    return render(request, 'volunteers/category_schedule_list.html', context)
Exemplo n.º 2
0
def category_schedule_list(request):
    categories = TaskCategory.objects.filter(active=True)
    context = {'categories': SortedDict.fromkeys(categories, [])}
    for category in context['categories']:
        context['categories'][category] = TaskTemplate.objects.filter(
            category=category)
    return render(request, 'volunteers/category_schedule_list.html', context)
Exemplo n.º 3
0
 def before(self, api, symbol):
     kwargs = SortedDict.fromkeys(('MASTER', 'IP', 'SYMBOL'), '')
     kwargs.update({
         'MASTER': settings.MT4_PLUGIN_CONTRACT_SPECS_PASSWORD,
         'IP': '127.0.0.1',
         'SYMBOL': symbol
     })
     return super(Symbol, self).before(api, **kwargs)
Exemplo n.º 4
0
def task_schedule(request, template_id):
    template = TaskTemplate.objects.filter(id=template_id)[0]
    tasks = Task.objects.filter(template=template).order_by('date', 'start_time', 'end_time')
    context = {
        'template': template,
        'tasks': SortedDict.fromkeys(tasks, {}),
    }
    for task in context['tasks']:
        context['tasks'][task] = Volunteer.objects.filter(tasks=task)
    return render(request, 'volunteers/task_schedule.html', context)
Exemplo n.º 5
0
def task_schedule(request, template_id):
    template = TaskTemplate.objects.filter(id=template_id)[0]
    tasks = Task.objects.filter(template=template,
                                edition=Edition.get_current).order_by(
                                    'date', 'start_time', 'end_time')
    context = {
        'template': template,
        'tasks': SortedDict.fromkeys(tasks, {}),
    }
    for task in context['tasks']:
        context['tasks'][task] = Volunteer.objects.filter(tasks=task)
    return render(request, 'volunteers/task_schedule.html', context)
Exemplo n.º 6
0
def task_list(request):
    # get the signed in volunteer
    if request.user.is_authenticated():
        volunteer = Volunteer.objects.get(user=request.user)
    else:
        volunteer = None
        is_dr_manhattan = False
    current_tasks = Task.objects.filter(edition=Edition.get_current)
    if volunteer:
        is_dr_manhattan, dr_manhattan_tasks = volunteer.detect_dr_manhattan()
        if dr_manhattan_tasks:
            dr_manhattan_task_ids = [
                x.id for x in set.union(*dr_manhattan_tasks)
            ]
        else:
            dr_manhattan_task_ids = []
        ok_tasks = current_tasks.exclude(id__in=dr_manhattan_task_ids)
    else:
        ok_tasks = current_tasks
    days = sorted(list(set([x.date for x in current_tasks])))

    # when the user submitted the form
    if request.method == 'POST' and volunteer:
        # get the checked tasks
        task_ids = request.POST.getlist('task')

        # unchecked boxes, delete him/her from the task
        for task in current_tasks.exclude(id__in=task_ids):
            VolunteerTask.objects.filter(task=task,
                                         volunteer=volunteer).delete()

        # checked boxes, add the volunteer to the tasks when he/she is not added
        for task in current_tasks.filter(id__in=task_ids):
            VolunteerTask.objects.get_or_create(task=task, volunteer=volunteer)

        # show success message when enabled
        if userena_settings.USERENA_USE_MESSAGES:
            messages.success(request,
                             _('Your tasks have been updated.'),
                             fail_silently=True)

        # redirect to prevent repost
        return redirect('task_list')

    # get the preferred and other tasks, preserve key order with sorteddict for
    # view
    context = {
        'tasks': SortedDict({}),
        'checked': {},
        'attending': {},
        'is_dr_manhattan': is_dr_manhattan,
    }
    # get the categories the volunteer is interested in
    if volunteer:
        categories_by_task_pref = {
            'preferred tasks':
            TaskCategory.objects.filter(volunteer=volunteer, active=True),
            'other tasks':
            TaskCategory.objects.filter(active=True).exclude(
                volunteer=volunteer),
        }
        context['volunteer'] = volunteer
        context['dr_manhattan_tasks'] = dr_manhattan_tasks
        context['tasks']['preferred tasks'] = SortedDict.fromkeys(days, {})
        context['tasks']['other tasks'] = SortedDict.fromkeys(days, {})
    else:
        categories_by_task_pref = {
            # 'preferred tasks': [],
            'tasks': TaskCategory.objects.filter(active=True),
        }
        context['tasks']['tasks'] = SortedDict.fromkeys(days, {})
    context['user'] = request.user
    for category_group in context['tasks']:
        for day in context['tasks'][category_group]:
            context['tasks'][category_group][day] = SortedDict.fromkeys(
                categories_by_task_pref[category_group], [])
            for category in context['tasks'][category_group][day]:
                dct = ok_tasks.filter(template__category=category, date=day)
                context['tasks'][category_group][day][category] = dct

    # mark checked, attending tasks
    if volunteer:
        for task in current_tasks:
            if volunteer in task.volunteers.all():
                context['checked'][task.id] = 'checked'
            else:
                context['checked'][task_id] = ''
            context['attending'][task.id] = False

        # take the moderation tasks to talks the volunteer is attending
        for task in current_tasks.filter(talk__volunteers=volunteer):
            context['attending'][task.id] = True
        check_profile_completeness(request, volunteer)
    else:
        for task in current_tasks:
            context['attending'][task.id] = False

    return render(request, 'volunteers/tasks.html', context)
Exemplo n.º 7
0
def task_list(request):
    # get the signed in volunteer
    volunteer = Volunteer.objects.get(user=request.user)
    is_dr_manhattan, dr_manhattan_task_sets = volunteer.detect_dr_manhattan()
    dr_manhattan_task_ids = [x.id for x in set.union(*dr_manhattan_task_sets)] if dr_manhattan_task_sets else []
    current_tasks = Task.objects.filter(date__year=Edition.get_current_year())
    ok_tasks = current_tasks.exclude(id__in=dr_manhattan_task_ids)
    throwaway = current_tasks.order_by('date').distinct('date')
    days = [x.date for x in throwaway]

    # when the user submitted the form
    if request.method == 'POST':
        # get the checked tasks
        task_ids = request.POST.getlist('task')

        # checked boxes, add the volunteer to the tasks when he/she is not added
        for task in Task.objects.filter(id__in=task_ids):
            VolunteerTask.objects.get_or_create(task=task, volunteer=volunteer)

        # unchecked boxes, delete him/her from the task
        for task in Task.objects.exclude(id__in=task_ids):
            VolunteerTask.objects.filter(task=task, volunteer=volunteer).delete()

        # show success message when enabled
        if userena_settings.USERENA_USE_MESSAGES:
            messages.success(request, _('Your tasks have been updated.'), fail_silently=True)

        # redirect to prevent repost
        return redirect('/tasks')

    # get the categories the volunteer is interested in
    categories_by_task_pref = {
        'preferred tasks': TaskCategory.objects.filter(volunteer=volunteer),
        'other tasks': TaskCategory.objects.exclude(volunteer=volunteer),
    }
    # get the preferred and other tasks, preserve key order with srteddict for view
    context = {
        'tasks': SortedDict({}),
        'checked': {},
        'attending': {},
        'is_dr_manhattan': is_dr_manhattan,
        'dr_manhattan_task_sets': dr_manhattan_task_sets,
    }
    context['volunteer'] = volunteer
    context['tasks']['preferred tasks'] = SortedDict.fromkeys(days, {})
    context['tasks']['other tasks'] = SortedDict.fromkeys(days, {})
    for category_group in context['tasks']:
        for day in context['tasks'][category_group]:
            context['tasks'][category_group][day] = SortedDict.fromkeys(categories_by_task_pref[category_group], [])
            for category in context['tasks'][category_group][day]:
                dct = ok_tasks.filter(template__category=category, date=day)
                context['tasks'][category_group][day][category] = dct

    # mark checked, attending tasks
    for task in current_tasks:
        context['checked'][task.id] = 'checked' if volunteer in task.volunteers.all() else ''

    # take the moderation tasks to talks the volunteer is attending
    for task in current_tasks.filter(talk__volunteers=volunteer):
        context['attending'][task.id] = True

    return render(request, 'volunteers/tasks.html', context)
Exemplo n.º 8
0
def task_list(request):
    # get the signed in volunteer
    if request.user.is_authenticated():
        volunteer = Volunteer.objects.get(user=request.user)
    else:
        volunteer = None
        is_dr_manhattan = False
    current_tasks = Task.objects.filter(edition=Edition.get_current)
    if volunteer:
        is_dr_manhattan, dr_manhattan_tasks = volunteer.detect_dr_manhattan()
        if dr_manhattan_tasks:
            dr_manhattan_task_ids = [
                x.id for x in set.union(*dr_manhattan_tasks)
            ]
        else:
            dr_manhattan_task_ids = []
        ok_tasks = current_tasks.exclude(id__in=dr_manhattan_task_ids)
    else:
        ok_tasks = current_tasks
    days = sorted(list(set([x.date for x in current_tasks])))

    # when the user submitted the form
    if request.method == 'POST' and volunteer:
        # get the checked tasks
        task_ids = request.POST.getlist('task')

        # unchecked boxes, delete him/her from the task
        for task in current_tasks.exclude(id__in=task_ids):
            VolunteerTask.objects.filter(
                task=task,
                volunteer=volunteer).delete()

        # checked boxes, add the volunteer to the tasks when he/she is not added
        for task in current_tasks.filter(id__in=task_ids):
            VolunteerTask.objects.get_or_create(task=task, volunteer=volunteer)

        # show success message when enabled
        if userena_settings.USERENA_USE_MESSAGES:
            messages.success(
                request,
                _('Your tasks have been updated.'),
                fail_silently=True)

        # redirect to prevent repost
        return redirect('task_list')

    # get the preferred and other tasks, preserve key order with sorteddict for
    # view
    context = {
        'tasks': SortedDict({}),
        'checked': {},
        'attending': {},
        'is_dr_manhattan': is_dr_manhattan,
    }
    # get the categories the volunteer is interested in
    if volunteer:
        categories_by_task_pref = {
            'preferred tasks': TaskCategory.objects.filter(
                volunteer=volunteer,
                active=True),
            'other tasks': TaskCategory.objects.filter(
                active=True).exclude(volunteer=volunteer),
        }
        context['volunteer'] = volunteer
        context['dr_manhattan_tasks'] = dr_manhattan_tasks
        context['tasks']['preferred tasks'] = SortedDict.fromkeys(days, {})
        context['tasks']['other tasks'] = SortedDict.fromkeys(days, {})
    else:
        categories_by_task_pref = {
            # 'preferred tasks': [],
            'tasks': TaskCategory.objects.filter(active=True),
        }
        context['tasks']['tasks'] = SortedDict.fromkeys(days, {})
    context['user'] = request.user
    for category_group in context['tasks']:
        for day in context['tasks'][category_group]:
            context['tasks'][category_group][day] = SortedDict.fromkeys(
                categories_by_task_pref[category_group], [])
            for category in context['tasks'][category_group][day]:
                dct = ok_tasks.filter(template__category=category, date=day)
                context['tasks'][category_group][day][category] = dct

    # mark checked, attending tasks
    if volunteer:
        for task in current_tasks:
            if volunteer in task.volunteers.all():
                context['checked'][task.id] = 'checked'
            else:
                context['checked'][task_id] = ''
            context['attending'][task.id] = False

        # take the moderation tasks to talks the volunteer is attending
        for task in current_tasks.filter(talk__volunteers=volunteer):
            context['attending'][task.id] = True
        check_profile_completeness(request, volunteer)
    else:
        for task in current_tasks:
            context['attending'][task.id] = False

    return render(request, 'volunteers/tasks.html', context)