diff --git a/python/nav/alertengine/base.py b/python/nav/alertengine/base.py index 1698ed2744..9247b2230f 100644 --- a/python/nav/alertengine/base.py +++ b/python/nav/alertengine/base.py @@ -103,7 +103,7 @@ 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: @@ -111,7 +111,7 @@ def check_alerts(debug=False): 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 ) @@ -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 ): @@ -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) @@ -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 @@ -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, ) @@ -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, @@ -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, @@ -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: @@ -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, diff --git a/python/nav/models/profiles.py b/python/nav/models/profiles.py index c5d97f0203..43118f5ecc 100644 --- a/python/nav/models/profiles.py +++ b/python/nav/models/profiles.py @@ -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 @@ -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: @@ -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: @@ -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): @@ -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 """ @@ -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 @@ -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')), @@ -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', @@ -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. """ @@ -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('|')) @@ -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' @@ -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', @@ -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) @@ -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', @@ -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')