Beispiel #1
0
def service_list():
    """
    This view lists all service events that
    are in the future with the nearest in time
    appearing first.

    It also lists old service events at the bottom
    """

    can_edit = members.can_edit(['webmaster'])

    now = dt.datetime.now()
    
    query = models.ServiceEventModel.all()
    query.filter('start_time >', now)
    query.order('start_time')

    future_events = query.fetch(query.count())
    for event in future_events:
        event = prepare_service_event(event)
        

    query = models.ServiceEventModel.all()
    query.filter('start_time <=', now)
    query.order('-start_time')

    past_events = query.fetch(query.count())
    for event in past_events:
        event = prepare_service_event(event)

    
    return render_template('service/list.html',
                           can_edit=can_edit,
                           future_events=future_events,
                           past_events = past_events)
def service_list():
    """
    This view lists all service events that
    are in the future with the nearest in time
    appearing first.

    It also lists old service events at the bottom
    """

    can_edit = members.can_edit(['webmaster'])

    now = dt.datetime.now()

    query = models.ServiceEventModel.all()
    query.filter('start_time >', now)
    query.order('start_time')

    future_events = query.fetch(query.count())
    for event in future_events:
        event = prepare_service_event(event)

    query = models.ServiceEventModel.all()
    query.filter('start_time <=', now)
    query.order('-start_time')

    past_events = query.fetch(query.count())
    for event in past_events:
        event = prepare_service_event(event)

    return render_template('service/list.html',
                           can_edit=can_edit,
                           future_events=future_events,
                           past_events=past_events)
def service_report_status(event_name, event_time):
    """
    This view displays and processes hour report statuses
    """

    event = get_service_event(event_name, event_time)
    if event is None:
        return render_template('404.html'), 404

    event = prepare_service_event(event)

    can_edit = members.can_edit(['webmaster'])

    if request.method == 'POST' and can_edit is not None:
        form = forms.ServiceReportReviewForm()
        if form.validate():
            for hour_review in form.hour_reviews:

                query = models.ServiceHourModel.all()
                reports = query.fetch(query.count())

                for report in reports:
                    if str(report.key()) == hour_review.hour_report_id.data:
                        new_status = hour_review.status.data
                        old_status = report.status
                        report.status = new_status
                        report.put()
                        update_contract_time_progress(report, old_status,
                                                      new_status)
                        break

            return render_template('service/show_report.html',
                                   can_edit=can_edit,
                                   event=event,
                                   event_review=form)
        else:
            flash(form.errors)
    else:
        form = create_service_report_review_form(event=event)

    return render_template('service/show_report.html',
                           can_edit=can_edit,
                           event=event,
                           event_review=form)
Beispiel #4
0
def service_report_status(event_name, event_time):
    """
    This view displays and processes hour report statuses
    """

    event = get_service_event(event_name, event_time)
    if event is None:
        return render_template('404.html'), 404

    event = prepare_service_event(event)

    can_edit = members.can_edit(['webmaster'])

    if request.method == 'POST' and can_edit is not None:
        form = forms.ServiceReportReviewForm()
        if form.validate():
            for hour_review in form.hour_reviews:
                
                query = models.ServiceHourModel.all()
                reports = query.fetch(query.count())

                for report in reports:
                    if str(report.key()) == hour_review.hour_report_id.data:
                        new_status = hour_review.status.data
                        old_status = report.status
                        report.status = new_status
                        report.put()
                        update_contract_time_progress(report, old_status, new_status)
                        break
                        
            return render_template('service/show_report.html',
                                   can_edit=can_edit,
                                   event=event,
                                   event_review=form)
        else:
            flash(form.errors)
    else:
        form = create_service_report_review_form(event=event)

    return render_template('service/show_report.html',
                           can_edit=can_edit,
                           event=event,
                           event_review=form)
Beispiel #5
0
def service_show_event(event_name, event_time):
    """
    This view displays a single service event
    and allows a user to sign up if there are spots avaiable
    """

    event = get_service_event(event_name, event_time)

    if event is None:
        return render_template('404.html'), 404
    
    event = prepare_service_event(event)
    
    signed_up = is_signed_up(event)

    signups = get_signups(event)

    full = None
    if event.maxBro is not None and len(signups) >= event.maxBro:
        full = True

    future = None
    if event.start_time > dt.datetime.now():
        future = True

    service_report = get_service_report(event)

    return render_template('service/show.html',
                           can_edit=members.can_edit(['webmaster']),
                           event=event,
                           signed_up=signed_up,
                           future=future,
                           full=full,
                           signups=signups,
                           service_report=service_report,
                           num_signed_up=len(signups))
def service_show_event(event_name, event_time):
    """
    This view displays a single service event
    and allows a user to sign up if there are spots avaiable
    """

    event = get_service_event(event_name, event_time)

    if event is None:
        return render_template('404.html'), 404

    event = prepare_service_event(event)

    signed_up = is_signed_up(event)

    signups = get_signups(event)

    full = None
    if event.maxBro is not None and len(signups) >= event.maxBro:
        full = True

    future = None
    if event.start_time > dt.datetime.now():
        future = True

    service_report = get_service_report(event)

    return render_template('service/show.html',
                           can_edit=members.can_edit(['webmaster']),
                           event=event,
                           signed_up=signed_up,
                           future=future,
                           full=full,
                           signups=signups,
                           service_report=service_report,
                           num_signed_up=len(signups))