コード例 #1
0
ファイル: tasks.py プロジェクト: HardSkript/test-auth
def blacklist_check():
    log = blacklist_check.get_logger()

    users = User.objects.filter(is_active=True)

    alerts = 0
    msg = ""

    for u in users:
        if u.groups.count() > 0:
            # Has groups
            val = blacklist_values(u)
            if len(val) > 0:
                alerts += 1
                # Report possible issue
                log.warning("Suspect User: %s, %s entries found: %s" % (u.username, len(val), val))

                blstr = ""
                for i in val:
                    blstr = "%s%s - %s - %s\n" % (blstr, i.get_type_display(), i.value, i.reason)

                msg += "\n\n-----\n\n"
                msg += "Suspect User found: %s\nGroups: %s\nBlacklist Items:\n\n%s" % (u.username, ", ".join(u.groups.all().values_list('name', flat=True)), blstr)

    if alerts:
        send_mail('Automated blacklist checker alerts', msg, '*****@*****.**', ['*****@*****.**'])
コード例 #2
0
ファイル: views.py プロジェクト: HardSkript/test-auth
    def get_context_data(self, **kwargs):
        ctx = super(UserDetailView, self).get_context_data(**kwargs)
        ctx.update({
            'profile': self.object.get_profile(),
            'services':  ServiceAccount.objects.select_related('service').filter(user=self.object).only('service__name', 'service_uid', 'active'),
            'characters': EVEPlayerCharacter.objects.select_related('corporation', 'corporation__alliance').filter(eveaccount__user=self.object).only('id', 'name', 'corporation__name'),
        })

        # If the HR app is installed, check the blacklist
        if installed('hr'):
            if self.request.user.has_perm('hr.add_blacklist'):
                from hr.utils import blacklist_values
                output = blacklist_values(self.object)
                ctx.update({
                    'blacklisted': bool(len(output)),
                    'blacklist_items': output,
                })

        return ctx
コード例 #3
0
ファイル: models.py プロジェクト: HardSkript/test-auth
 def blacklist_values(self):
     if not hasattr(self, '_blcache'):
         from hr.utils import blacklist_values
         self._blcache = blacklist_values(self.user)
     return self._blcache