Skip to content

Commit

Permalink
[Fixes #5283] UnicodeEncodeError when trying to delete a Layer on a G…
Browse files Browse the repository at this point in the history
…eoNode instance with action streams containing exotic characters.

(cherry picked from commit 721562c)
  • Loading branch information
afabiani committed Nov 18, 2019
1 parent f318bbd commit 175e4fd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion geonode/geoserver/helpers.py
Expand Up @@ -1511,7 +1511,7 @@ def hostname(self):
def netloc(self):
return urlsplit(self.LOCATION).netloc

def __str__(self):
def __unicode__(self):
return self.alias


Expand Down
2 changes: 1 addition & 1 deletion geonode/groups/models.py
Expand Up @@ -44,7 +44,7 @@ class GroupCategory(models.Model):
class Meta:
verbose_name_plural = _('Group Categories')

def __str__(self):
def __unicode__(self):
return 'Category: {}'.format(self.name.encode('utf-8'))

def get_absolute_url(self):
Expand Down
24 changes: 12 additions & 12 deletions geonode/monitoring/models.py
Expand Up @@ -83,7 +83,7 @@ class Host(models.Model):
ip = models.GenericIPAddressField(null=False, blank=False)
active = models.BooleanField(null=False, blank=False, default=True)

def __str__(self):
def __unicode__(self):
return 'Host: {} ({})'.format(self.name, self.ip)


Expand All @@ -109,7 +109,7 @@ class ServiceType(models.Model):
null=False,
choices=TYPES)

def __str__(self):
def __unicode__(self):
return 'Service Type: {}'.format(self.name)

@property
Expand All @@ -136,7 +136,7 @@ class Service(models.Model):
notes = models.TextField(null=True, blank=True)
url = models.URLField(null=True, blank=True, default='')

def __str__(self):
def __unicode__(self):
return 'Service: {}@{}'.format(self.name, self.host.name)

def get_metrics(self):
Expand Down Expand Up @@ -191,7 +191,7 @@ class MonitoredResource(models.Model):
class Meta:
unique_together = (('name', 'type',),)

def __str__(self):
def __unicode__(self):
return 'Monitored Resource: {} {}'.format(self.name, self.type)

@classmethod
Expand Down Expand Up @@ -282,7 +282,7 @@ def get_aggregate_field(self):
def get_aggregate_name(self):
return self.AGGREGATE_MAP[self.type]

def __str__(self):
def __unicode__(self):
return "Metric: {}".format(self.name)

@property
Expand Down Expand Up @@ -320,7 +320,7 @@ class ServiceTypeMetric(models.Model):
service_type = models.ForeignKey(ServiceType, related_name='metric')
metric = models.ForeignKey(Metric, related_name='service_type')

def __str__(self):
def __unicode__(self):
return '{} - {}'.format(self.service_type, self.metric)


Expand Down Expand Up @@ -367,7 +367,7 @@ class EventType(models.Model):
null=False,
blank=False)

def __str__(self):
def __unicode__(self):
return 'Event Type: {}'.format(self.name)

@classmethod
Expand Down Expand Up @@ -895,7 +895,7 @@ class MetricLabel(models.Model):
null=True,
blank=True)

def __str__(self):
def __unicode__(self):
return 'Metric Label: {}'.format(self.name.encode('ascii', 'ignore'))


Expand Down Expand Up @@ -938,7 +938,7 @@ class Meta:
'event_type',
))

def __str__(self):
def __unicode__(self):
metric = self.service_metric.metric.name
if self.label:
_l = self.label.name
Expand Down Expand Up @@ -1118,7 +1118,7 @@ class NotificationCheck(models.Model):
blank=False,
help_text=_("Is it active"))

def __str__(self):
def __unicode__(self):
return "Notification Check #{}: {}".format(self.id, self.name)

@property
Expand Down Expand Up @@ -1550,7 +1550,7 @@ class MetricNotificationCheck(models.Model):
null=True,
related_name='metric_check')

def __str__(self):
def __unicode__(self):
indicator = []
if self.min_value is not None:
indicator.append("value above {}".format(self.min_value))
Expand Down Expand Up @@ -1596,7 +1596,7 @@ def __init__(self, metric, check, message,

self.valid_from, self.valid_to = metric.valid_from, metric.valid_to

def __str__(self):
def __unicode__(self):
return "MetricValueError({}: metric {} misses {} check: {})".format(self.severity,
self.metric,
self.check,
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Expand Up @@ -62,7 +62,7 @@ django-celery-monitor<=1.1.2
django-celery-beat==1.5.0
django-floppyforms<1.9.0
django-forms-bootstrap<=3.1.0
django-activity-stream==0.8.0
geonode-django-activity-stream==0.9.0
django-autocomplete-light<3.0.0
django-basic-authentication-decorator==0.9
django-leaflet==0.25.0
Expand Down

0 comments on commit 175e4fd

Please sign in to comment.