<commit_before><style type="text/css">
  #volunteers {
    position: fixed;
    right: 15px;
    top: 15px;
    text-align: right;
    box-shadow: 0 0 5px 5px rgba(0, 0, 0, 0.075);
    z-index: 1001;
  }

  #jobs {
    max-width: 1024px;
    width: 100%;
  }

  #jobs > tbody > tr:first-child {
    background-color: #f0f0f0;
  }

  #jobs td {
    padding: 5px;
  }

  #jobs td:first-child {
    padding-left: 10px;
  }

  #jobs td:last-child {
    padding-right: 10px;
  }

  #jobs tr.shifts-row > td {
    padding: 5px 0 15px 0;
  }

  #jobs .shifts-table td.attendee-name {
    padding-left: 15px;
  }

  #jobs .shifts-table td.attendee-name:before {
    content: '\25cf';
    display: inline-block;
    margin-right: 10px;
  }

  #jobs .shifts-table .rating img {
    cursor: pointer;
    margin: 0 5px;
  }
</style>

<script type="text/javascript" src="../static_views/ratings.js"></script>

<div id="volunteers" class="panel panel-default">
  <div class="panel-body">
    <b>Assign someone to any of these positions</b> <br/>
    <select id="attendee">
        <option value="">Select a volunteer</option>
        {% for attendee in attendees %}
            <option value="{{ attendee.id }}">{{ attendee.full_name }}</option>
        {% endfor %}
    </select>
  </div>
</div>

<div class="table-responsive">
  <table id="jobs"></table>
</div>

<script>
    $(setupShiftRatingClickHandler);

    var renderShift = function(shift) {
        return $id('shift_' + shift.id, '<tr></tr>')
            .empty()
            .append(
                $('<td class="attendee-name"></td>').append(
                    $('<a href="../registration/shifts?id=' + shift.attendee_id + '"></a>').text(
                        shift.attendee_name  + ' (#' + (shift.attendee_badge || 'TBD') + ')'
                    )
                ))
            .append(
                $('<td class="text-right"></td>').append(
                    $('<button class="btn btn-xs btn-warning">Unassign</button>').click(function() {
                        $.post('unassign', {
                            csrf_token: csrf_token,
                            id: shift.id
                        }, renderJob, 'json');
                    }))
                )
            .append($('<td></td>').append(renderShiftStatus(shift, renderShifts)))
            .append($('<td></td>').append(renderShiftRating(shift)));
    };

    var renderShifts = function(job) {
        if (job.error) {
            alert(job.error);
            return;
        }

        var shifts = job.shifts.sort(function(s1, s2) {
            return s1.attendee_name > s2.attendee_name;
        });
        return $id('shifts_' + job.id, '<table class="shifts-table"></table>')
            .empty()
            .append($.map(shifts, renderShift));
    };

    var renderJob = function(job) {
        if (job.error) {
            alert(job.error);
            return;
        }

        var jobIsFull = job.slots <= job.shifts.length;
        if (!window.SHOW_FULL_JOBS && jobIsFull) {
            return '';
        }
        return $id('job_' + job.id, '<tbody></tbody>')
            .empty()
            .append(
                $('<tr></tr>')
                    .append('<td><b>' + job.timespan + ':</b> [x' + job.weight + '] </td>')
                    .append(
                        '<td>' +
                            (job.restricted ? '[R] ' : '') +
                            '<a href="form?id=' + job.id + '"><b>' + job.name + '</b></a>' +
                            ' (' + job.department_name + ')' +
                        '</td>')
                    .append('<td><span class="text-nowrap">(' + job.shifts.length + '/' + job.slots + ' slots filled)</span></td>')
                    .append(
                        $('<td class="text-right"></td>').append(
                            jobIsFull ? '' : $('<button class="btn btn-xs btn-success">Assign</button>').click(function() {
                                var attendee = $('#attendee').val();
                                if (attendee) {
                                    $.post('assign', {
                                        csrf_token: csrf_token,<commit_msg>Fixes issue were assigning last slot in a job<commit_after><style type="text/css">
  #volunteers {
    position: fixed;
    right: 15px;
    top: 15px;
    text-align: right;
    box-shadow: 0 0 5px 5px rgba(0, 0, 0, 0.075);
    z-index: 1001;
  }

  #jobs {
    max-width: 1024px;
    width: 100%;
  }

  #jobs > tbody > tr:first-child {
    background-color: #f0f0f0;
  }

  #jobs td {
    padding: 5px;
  }

  #jobs td:first-child {
    padding-left: 10px;
  }

  #jobs td:last-child {
    padding-right: 10px;
  }

  #jobs tr.shifts-row > td {
    padding: 5px 0 15px 0;
  }

  #jobs .shifts-table td.attendee-name {
    padding-left: 15px;
  }

  #jobs .shifts-table td.attendee-name:before {
    content: '\25cf';
    display: inline-block;
    margin-right: 10px;
  }

  #jobs .shifts-table .rating img {
    cursor: pointer;
    margin: 0 5px;
  }
</style>

<script type="text/javascript" src="../static_views/ratings.js"></script>

<div id="volunteers" class="panel panel-default">
  <div class="panel-body">
    <b>Assign someone to any of these positions</b> <br/>
    <select id="attendee">
        <option value="">Select a volunteer</option>
        {% for attendee in attendees %}
            <option value="{{ attendee.id }}">{{ attendee.full_name }}</option>
        {% endfor %}
    </select>
  </div>
</div>

<div class="table-responsive">
  <table id="jobs"></table>
</div>

<script>
    $(setupShiftRatingClickHandler);

    var renderShift = function(shift) {
        return $id('shift_' + shift.id, '<tr></tr>')
            .empty()
            .append(
                $('<td class="attendee-name"></td>').append(
                    $('<a href="../registration/shifts?id=' + shift.attendee_id + '"></a>').text(
                        shift.attendee_name  + ' (#' + (shift.attendee_badge || 'TBD') + ')'
                    )
                ))
            .append(
                $('<td class="text-right"></td>').append(
                    $('<button class="btn btn-xs btn-warning">Unassign</button>').click(function() {
                        $.post('unassign', {
                            csrf_token: csrf_token,
                            id: shift.id
                        }, renderJob, 'json');
                    }))
                )
            .append($('<td></td>').append(renderShiftStatus(shift, renderShifts)))
            .append($('<td></td>').append(renderShiftRating(shift)));
    };

    var renderShifts = function(job) {
        if (job.error) {
            alert(job.error);
            return;
        }

        var shifts = job.shifts.sort(function(s1, s2) {
            return s1.attendee_name > s2.attendee_name;
        });
        return $id('shifts_' + job.id, '<table class="shifts-table"></table>')
            .empty()
            .append($.map(shifts, renderShift));
    };

    var renderJob = function(job) {
        if (job.error) {
            alert(job.error);
            return;
        }

        var jobIsFull = job.slots <= job.shifts.length;
        if (!window.SHOW_FULL_JOBS && jobIsFull && !$('#job_' + job.id).length) {
            return '';
        }
        return $id('job_' + job.id, '<tbody></tbody>')
            .empty()
            .append(
                $('<tr></tr>')
                    .append('<td><b>' + job.timespan + ':</b> [x' + job.weight + '] </td>')
                    .append(
                        '<td>' +
                            (job.restricted ? '[R] ' : '') +
                            '<a href="form?id=' + job.id + '"><b>' + job.name + '</b></a>' +
                            ' (' + job.department_name + ')' +
                        '</td>')
                    .append('<td><span class="text-nowrap">(' + job.shifts.length + '/' + job.slots + ' slots filled)</span></td>')
                    .append(
                        $('<td class="text-right"></td>').append(
                            jobIsFull ? '' : $('<button class="btn btn-xs btn-success">Assign</button>').click(function() {
                                var attendee = $('#attendee').val();
                                if (attendee) {
                                    $.post('assign', {
                                        csrf_token: csrf_token,
{'fraction_non_alphanumeric': 0.17544690422635256, 'fraction_numerical': 0.012075293003433171, 'mean_word_length': 1.5346534653465347, 'pattern_counts': {'":': 0, '<': 125, '<?xml version=': 0, '>': 131, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4108607', 'n_tokens_mistral': 2793, 'n_tokens_neox': 2572, 'n_words': 485}