Skip to content

Commit

Permalink
Fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaengland committed Sep 14, 2023
1 parent 59f8014 commit 0358511
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 35 deletions.
22 changes: 11 additions & 11 deletions python/nav/alertengine/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ def check_alerts(debug=False):
num_resolved_alerts_ignored,
) = ([], [], 0, 0, 0)

# Update the when the user last recieved daily or weekly alerts.
# Update the time when the user last received daily or weekly alerts.
if sent_daily:
AlertPreference.objects.filter(account__in=sent_daily).update(last_sent_day=now)
if sent_weekly:
AlertPreference.objects.filter(account__in=sent_weekly).update(
last_sent_week=now
)

# Get id's of alerts that have been queued for users.
# Get ids of alerts that have been queued for users.
alerts_in_account_queues = AccountAlertQueue.objects.values_list(
'alert_id', flat=True
)
Expand Down Expand Up @@ -181,7 +181,7 @@ def subscription_sort_key(subscription):
return subscription.type

# Build datastructure that contains accounts and corresponding
# filter_group_contents so that we don't redo db queries to much
# filter_group_contents so that we don't redo db queries too much
for account in Account.objects.filter(
alert_preference__active_profile__isnull=False
):
Expand Down Expand Up @@ -221,7 +221,7 @@ def subscription_sort_key(subscription):
# Remember which alerts are sent where to avoid duplicates
dupemap = set()

# Check all acounts against all their active subscriptions
# Check all accounts against all their active subscriptions
for account, alertsubscriptions, permissions in accounts:
_logger.debug("Checking new alerts for account '%s'", account)

Expand Down Expand Up @@ -422,7 +422,7 @@ def process_single_queued_notification(queued_alert, now):

if subscription is None:
_logger.info(
'Sending alert %d right away as the users profile has ' 'been disabled',
'Sending alert %d right away as the users profile has been disabled',
queued_alert.alert_id,
)
send = True
Expand All @@ -446,7 +446,7 @@ def process_single_queued_notification(queued_alert, now):

else:
_logger.error(
'Account %s has an invalid subscription type in ' 'subscription %d',
'Account %s has an invalid subscription type in subscription %d',
subscription.account,
subscription.id,
)
Expand Down Expand Up @@ -486,7 +486,7 @@ def _verify_daily_dispatch(queued_alert, now, _logger=_logger):
now.date(), daily_time
)
_logger.debug(
'Tests: last sent %s, daily time %s, insertion time ' '%s',
'Tests: last sent %s, daily time %s, insertion time %s',
last_sent_test,
daily_time_test,
insertion_time_test,
Expand Down Expand Up @@ -514,7 +514,7 @@ def _verify_weekly_dispatch(queued_alert, now, _logger=_logger):
)

_logger.debug(
'Tests: weekday %s, last sent %s, weekly time %s, ' 'insertion time %s',
'Tests: weekday %s, last sent %s, weekly time %s, insertion time %s',
weekday_test,
last_sent_test,
weekly_time_test,
Expand Down Expand Up @@ -610,11 +610,11 @@ def check_alert_against_filtergroupcontents(alert, filtergroupcontents, atype):
_logger.debug("Emtpy filtergroup")
return False

# Allways assume that the match will fail
# Always assume that the match will fail
matches = False

for content in filtergroupcontents:
original_macthes = matches
original_matches = matches

# If we have not matched the message see if we can match it
if not matches and content.include:
Expand All @@ -641,7 +641,7 @@ def check_alert_against_filtergroupcontents(alert, filtergroupcontents, atype):
atype,
)

if original_macthes == matches:
if original_matches == matches:
_logger.debug(
'alert %d: unaffected by filter %d in %s',
alert.id,
Expand Down
49 changes: 25 additions & 24 deletions python/nav/models/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@


# This should be the authorative source as to which models alertengine
# supports. The acctuall mapping from alerts to data in these models is done
# supports. The actual mapping from alerts to data in these models is done in
# the MatchField model.
SUPPORTED_MODELS = [
# event models
Expand Down Expand Up @@ -136,7 +136,7 @@ def get_active_profile(self):
pass

def get_groups(self):
"""Fetches and returns this users groups.
"""Fetches and returns this user's groups.
Also stores groups in this object for later use.
"""
try:
Expand All @@ -146,7 +146,7 @@ def get_groups(self):
return self._cached_groups

def get_privileges(self):
"""Fetches privileges for this users groups.
"""Fetches privileges for this user's groups.
Also stores privileges in this object for later use.
"""
try:
Expand Down Expand Up @@ -184,7 +184,7 @@ def has_perm(self, action, target):
return privileges.filter(target=target).count() > 0

def is_system_account(self):
"""Is this system (undeleteable) account?"""
"""Is this a system (undeleteable) account?"""
return self.id < 1000

def is_default_account(self):
Expand Down Expand Up @@ -405,7 +405,7 @@ def __str__(self):


class AlertAddress(models.Model):
"""Accounts alert addresses, valid types are retrived from
"""Accounts alert addresses, valid types are retrieved from
alertengine.conf
"""
Expand Down Expand Up @@ -794,9 +794,9 @@ class FilterGroupContent(models.Model):

# include and positive are used to decide how the match result of the
# filter should be applied. the table above is an attempt at showing how
# this should work. Add inv is really the only tricky one, basicly it is
# this should work. Add inv is really the only tricky one, basically it is
# nothing more that a negated add, ie if we have a filter that checks
# severity < 4 using a add inv on it is equivilent til severity >= 4.
# severity < 4 using an add inv on it is equivalent to severity >= 4.

# The actual checking of the FilterGroup is done in the alertengine
# subsystem in an attempt to keep most of the alerteninge code simple and
Expand Down Expand Up @@ -850,9 +850,9 @@ class Operator(models.Model):
IN = 11

# This list designates which operators are supported for any field. The
# only major special case is IP's which are matched with special pg ip
# only major special case is IPs which are matched with special pg ip
# operators where it makes sense, the rest of the operators are handeled
# with plain text comaparisons against the result of text(ip)
# with plain text comparisons against the result of text(ip)
OPERATOR_TYPES = (
(EQUALS, _('equals')),
(GREATER, _('is greater')),
Expand All @@ -868,8 +868,8 @@ class Operator(models.Model):
(IN, _('in')),
)

# This is the mapping that is jused when we try querying the ORM to se if
# filtes match. Note that wildcard is not here as it neeeds to be special
# This is the mapping that is used when we try querying the ORM to see if
# filters match. Note that wildcard is not here as it neeeds to be special
# cased.
OPERATOR_MAPPING = {
EQUALS: '__exact',
Expand Down Expand Up @@ -926,7 +926,7 @@ def get_ip_operator_mapping(self):


class Expression(models.Model):
"""Combines filer, operator, matchfield and value into an expression that
"""Combines filter, operator, matchfield and value into an expression that
can be evaluated.
"""
Expand Down Expand Up @@ -1024,7 +1024,7 @@ def verify(self, alert):
# Include all sublocations when matching on location
elif expression.match_field.name == 'Location':
lookup = "{}__in".format(MatchField.FOREIGN_MAP[MatchField.LOCATION])
# Location only have two Operators (in and exact) so we handle
# Location only has two Operators (in and exact) so we handle
# both with a split
locations = Location.objects.filter(pk__in=expression.value.split('|'))

Expand Down Expand Up @@ -1123,18 +1123,18 @@ class MatchField(models.Model):
INTEGER = 1
IP = 2

# Due to the way alertengine has been reimpleneted the code only really
# does stuff diffrently if datatype is set to IP, however setting datatype
# still makes alot of sense in alertprofiles so that we can verify
# userinput
# Due to the way alertengine has been reimplemented the code only really
# does stuff differently if datatype is set to IP, however setting datatype
# still makes a lot of sense in alertprofiles so that we can verify
# user input
DATA_TYPES = (
(STRING, _('string')),
(INTEGER, _('integer')),
(IP, _('ip')),
)

# This is a manualy mainted mapping between our model concepts and the
# actual db tables that are in use. This is needed as our value_id is base
# This is a manually maintained mapping between our model concepts and the
# actual db tables that are in use. This is needed as our value_id is based
# on this value.
ALERT = 'alertq'
ALERTTYPE = 'alerttype'
Expand Down Expand Up @@ -1186,7 +1186,8 @@ class MatchField(models.Model):

# This mapping designates how a MatchField relates to an alert. (yes the
# formating is not PEP8, but it wouldn't be very readable otherwise)
# Since we need to know how things are connected this has been done manualy
# Since we need to know how things are connected this has been done
# manually
FOREIGN_MAP = {
ARP: 'netbox__arp_set',
CAM: 'netbox__cam_set',
Expand Down Expand Up @@ -1218,9 +1219,9 @@ class MatchField(models.Model):
MODEL_MAP = {}

# This code loops over all the SUPPORTED_MODELS and gets the db_table and
# db_column so that we can translate them into the correspinding attributes
# db_column so that we can translate them into the corresponding attributes
# on our django models. (field and model need to be set to None to avoid an
# ugly side effect of field becoming an acctuall field on MatchField)
# ugly side effect of field becoming an actual field on MatchField)
for model in SUPPORTED_MODELS:
for field in model._meta.fields:
key = '%s.%s' % (model._meta.db_table, field.db_column or field.attname)
Expand Down Expand Up @@ -1359,7 +1360,7 @@ def save(self, *args, **kwargs):


class AccountAlertQueue(models.Model):
"""Defines which alerts should be keept around and sent at a later time"""
"""Defines which alerts should be kept around and sent at a later time"""

account = models.ForeignKey(
'Account',
Expand Down Expand Up @@ -1620,7 +1621,7 @@ class Meta(object):


class AccountNavlet(models.Model):
"""Store information about a users navlets"""
"""Store information about a user's navlets"""

navlet = VarcharField()
order = models.IntegerField(default=0, db_column='displayorder')
Expand Down

0 comments on commit 0358511

Please sign in to comment.