Add the absence count to the context for students.
761493
def absence_count(request):
    """"""

    if request.user and request.user.is_authenticated and request.user.is_student:
        absence_info = request.user.absence_info()
        num_absences = absence_info.count()
        show_notif = False
        if num_absences > 0:
            notif_seen = request.session.get('eighth_absence_notif_seen', False)
            if not notif_seen:
                for signup in absence_info:
                    if signup.in_clear_absence_period():
                        show_notif = True

            if show_notif:
                request.session['eighth_absence_notif_seen'] = True

        return {"eighth_absence_count": num_absences, "eighth_absence_notif": show_notif}

    return {}
1100414
def set_unavailable(self):
        """"""
        show = PresenceShow.NONE
        self.set_presence(PresenceState(available=False, show=show))
84537
def step_impl07(context):
    
    assert context.st_1 is context.st_2
    assert context.st_2 is context.st_3
921222
def fill_missing(x):
    

    # find subject with max number of lists
    maxlen = max([len(xi) for xi in x])

    subs = []

    for sub in x:
        if len(sub)<maxlen:
            for i in range(maxlen-len(sub)):
                sub.append([])
            new_sub = sub
        else:
            new_sub = sub
        subs.append(new_sub)
    return subs
407354
def statistics(self, start=None, end=None, namespace=None):
        """"""
        return self.make_context(start=start, end=end,
                                 namespace=namespace).statistics()
184288
private void updateCountSpan() {
        //No count span with free form text
        if (!preventFreeFormText) { return; }

        Editable text = getText();

        int visibleCount = getText().getSpans(0, getText().length(), TokenImageSpan.class).length;
        countSpan.setCount(getObjects().size() - visibleCount);

        SpannableStringBuilder spannedCountText = new SpannableStringBuilder(countSpan.getCountText());
        spannedCountText.setSpan(countSpan, 0, spannedCountText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        internalEditInProgress = true;
        int countStart = text.getSpanStart(countSpan);
        if (countStart != -1) {
            //Span is in the text, replace existing text
            //This will also remove the span if the count is 0
            text.replace(countStart, text.getSpanEnd(countSpan), spannedCountText);
        } else {
            text.append(spannedCountText);
        }

        internalEditInProgress = false;
    }
1157972
def addSuccess(self, test, capt=None):
        """"""
        time_taken = self._register_time(test, 'success')
        if self.timer_fail is not None and time_taken * 1000.0 > self.threshold:
            test.fail('Test was too slow (took {0:0.4f}s, threshold was '
                      '{1:0.4f}s)'.format(time_taken, self.threshold / 1000.0))
642145
def absence_count(self):
        
        # FIXME: remove recursive dep
        from ..eighth.models import EighthSignup

        return EighthSignup.objects.filter(user=self, was_absent=True, scheduled_activity__attendance_taken=True).count()
587400
def _missing_(cls, value):
        """"""
        if not (isinstance(value, int) and 0 <= value <= 65535):
            raise ValueError('%r is not a valid %s' % (value, cls.__name__))
        if 0 <= value <= 64:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 66 <= value <= 127:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 130 <= value <= 192:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 194 <= value <= 256:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 258 <= value <= 320:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 322 <= value <= 384:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 386 <= value <= 448:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 450 <= value <= 510:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 514 <= value <= 576:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 580 <= value <= 607:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 611 <= value <= 640:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 642 <= value <= 704:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 706 <= value <= 714:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 716 <= value <= 767:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 769 <= value <= 831:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 833 <= value <= 896:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 898 <= value <= 929:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 937 <= value <= 949:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 951 <= value <= 960:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 962 <= value <= 2048:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 2050 <= value <= 4094:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 4096 <= value <= 4480:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 4482 <= value <= 4544:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 4546 <= value <= 4576:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 4578 <= value <= 4579:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 4581 <= value <= 4591:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 4593 <= value <= 4600:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 4602 <= value <= 7679:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 7681 <= value <= 32767:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 32768 <= value <= 49151:
        # [RFC 7401]
            extend_enum(cls, 'Reserved [%d]' % value, value)
            return cls(value)
        if 49152 <= value <= 61504:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 61506 <= value <= 61568:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 61570 <= value <= 61632:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 61634 <= value <= 61696:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 61698 <= value <= 63660:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 63662 <= value <= 63424:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 63426 <= value <= 63997:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 63999 <= value <= 64001:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 64003 <= value <= 64010:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 64012 <= value <= 64016:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 64018 <= value <= 65497:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 65503 <= value <= 65519:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        if 65521 <= value <= 65535:
            extend_enum(cls, 'Unassigned [%d]' % value, value)
            return cls(value)
        super()._missing_(value)
47746
def add(self, auth, method, args, notimeout=False):
        """"""
        authstr = self._authstr(auth)
        self._requests.setdefault(authstr, []).append((method, args))
        self._notimeouts.setdefault(authstr, False)
        if notimeout:
            self._notimeouts[authstr] = notimeout
282263
def users_setPresence(self, *, presence: str, **kwargs) -> SlackResponse:
        
        kwargs.update({"presence": presence})
        return self.api_call("users.setPresence", json=kwargs)
395075
def missing_count(self):
        """"""
        if self.means:
            return self.means.missing_count
        return self._cube_dict["result"].get("missing", 0)
610090
def missing(self, dst):
        
        for inst in six.itervalues(dst):
            if inst.status != REMOVED:
                inst.status = REMOVED
                inst.save()
1118405
def get_attendance(self):
        
        self.read_sizes()
        if self.records == 0:
            return []
        users = self.get_users()
        if self.verbose: print (users)
        attendances = []
        attendance_data, size = self.read_with_buffer(const.CMD_ATTLOG_RRQ)
        if size < 4:
            if self.verbose: print ("WRN: no attendance data")
            return []
        total_size = unpack("I", attendance_data[:4])[0]
        record_size = total_size/self.records
        if self.verbose: print ("record_size is ", record_size)
        attendance_data = attendance_data[4:]
        if record_size == 8:
            while len(attendance_data) >= 8:
                uid, status, timestamp, punch = unpack('HB4sB', attendance_data.ljust(8, b'\x00')[:8])
                if self.verbose: print (codecs.encode(attendance_data[:8], 'hex'))
                attendance_data = attendance_data[8:]
                tuser = list(filter(lambda x: x.uid == uid, users))
                if not tuser:
                    user_id = str(uid)
                else:
                    user_id = tuser[0].user_id
                timestamp = self.__decode_time(timestamp)
                attendance = Attendance(user_id, timestamp, status, punch, uid)
                attendances.append(attendance)
        elif record_size == 16:
            while len(attendance_data) >= 16:
                user_id, timestamp, status, punch, reserved, workcode = unpack('<I4sBB2sI', attendance_data.ljust(16, b'\x00')[:16])
                user_id = str(user_id)
                if self.verbose: print(codecs.encode(attendance_data[:16], 'hex'))
                attendance_data = attendance_data[16:]
                tuser = list(filter(lambda x: x.user_id == user_id, users))
                if not tuser:
                    if self.verbose: print("no uid {}", user_id)
                    uid = str(user_id)
                    tuser = list(filter(lambda x: x.uid == user_id, users))
                    if not tuser:
                        uid = str(user_id)
                    else:
                        uid = tuser[0].uid
                        user_id = tuser[0].user_id
                else:
                    uid = tuser[0].uid
                timestamp = self.__decode_time(timestamp)
                attendance = Attendance(user_id, timestamp, status, punch, uid)
                attendances.append(attendance)
        else:
            while len(attendance_data) >= 40:
                uid, user_id, status, timestamp, punch, space = unpack('<H24sB4sB8s', attendance_data.ljust(40, b'\x00')[:40])
                if self.verbose: print (codecs.encode(attendance_data[:40], 'hex'))
                user_id = (user_id.split(b'\x00')[0]).decode(errors='ignore')
                timestamp = self.__decode_time(timestamp)

                attendance = Attendance(user_id, timestamp, status, punch, uid)
                attendances.append(attendance)
                attendance_data = attendance_data[40:]
        return attendances
1337420
def extra_context(self, request, context):
        """"""
        if settings.PAGE_EXTRA_CONTEXT:
            context.update(settings.PAGE_EXTRA_CONTEXT())
365691
def respond_to_missing?(method, include_private = false)
      if method.to_s.starts_with? "*"
        condition_name = method.to_s.split("*")[1].to_sym
        conditions = self.class.scram_conditions
        if conditions && !conditions[condition_name].nil?
          return true
        end
      end
      super
    end
885723
def add_data(self, request, pk=None):
        """"""
        collection = self.get_object()

        if 'ids' not in request.data:
            return Response({"error": "`ids`parameter is required"}, status=status.HTTP_400_BAD_REQUEST)

        missing = []
        for data_id in request.data['ids']:
            if not Data.objects.filter(pk=data_id).exists():
                missing.append(data_id)

        if missing:
            return Response(
                {"error": "Data objects with following ids are missing: {}".format(', '.join(missing))},
                status=status.HTTP_400_BAD_REQUEST)

        for data_id in request.data['ids']:
            collection.data.add(data_id)

        return Response()