Skip to content

Commit 721562c

Browse files
author
afabiani
committed
[Fixes GeoNode#5283] UnicodeEncodeError when trying to delete a Layer on a GeoNode instance with action streams containing exotic characters.
1 parent e3c845f commit 721562c

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

Diff for: geonode/geoserver/helpers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,7 @@ def hostname(self):
15111511
def netloc(self):
15121512
return urlsplit(self.LOCATION).netloc
15131513

1514-
def __str__(self):
1514+
def __unicode__(self):
15151515
return self.alias
15161516

15171517

Diff for: geonode/groups/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class GroupCategory(models.Model):
4444
class Meta:
4545
verbose_name_plural = _('Group Categories')
4646

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

5050
def get_absolute_url(self):

Diff for: geonode/monitoring/models.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class Host(models.Model):
8383
ip = models.GenericIPAddressField(null=False, blank=False)
8484
active = models.BooleanField(null=False, blank=False, default=True)
8585

86-
def __str__(self):
86+
def __unicode__(self):
8787
return 'Host: {} ({})'.format(self.name, self.ip)
8888

8989

@@ -109,7 +109,7 @@ class ServiceType(models.Model):
109109
null=False,
110110
choices=TYPES)
111111

112-
def __str__(self):
112+
def __unicode__(self):
113113
return 'Service Type: {}'.format(self.name)
114114

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

139-
def __str__(self):
139+
def __unicode__(self):
140140
return 'Service: {}@{}'.format(self.name, self.host.name)
141141

142142
def get_metrics(self):
@@ -191,7 +191,7 @@ class MonitoredResource(models.Model):
191191
class Meta:
192192
unique_together = (('name', 'type',),)
193193

194-
def __str__(self):
194+
def __unicode__(self):
195195
return 'Monitored Resource: {} {}'.format(self.name, self.type)
196196

197197
@classmethod
@@ -282,7 +282,7 @@ def get_aggregate_field(self):
282282
def get_aggregate_name(self):
283283
return self.AGGREGATE_MAP[self.type]
284284

285-
def __str__(self):
285+
def __unicode__(self):
286286
return "Metric: {}".format(self.name)
287287

288288
@property
@@ -320,7 +320,7 @@ class ServiceTypeMetric(models.Model):
320320
service_type = models.ForeignKey(ServiceType, related_name='metric')
321321
metric = models.ForeignKey(Metric, related_name='service_type')
322322

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

326326

@@ -367,7 +367,7 @@ class EventType(models.Model):
367367
null=False,
368368
blank=False)
369369

370-
def __str__(self):
370+
def __unicode__(self):
371371
return 'Event Type: {}'.format(self.name)
372372

373373
@classmethod
@@ -895,7 +895,7 @@ class MetricLabel(models.Model):
895895
null=True,
896896
blank=True)
897897

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

901901

@@ -938,7 +938,7 @@ class Meta:
938938
'event_type',
939939
))
940940

941-
def __str__(self):
941+
def __unicode__(self):
942942
metric = self.service_metric.metric.name
943943
if self.label:
944944
_l = self.label.name
@@ -1118,7 +1118,7 @@ class NotificationCheck(models.Model):
11181118
blank=False,
11191119
help_text=_("Is it active"))
11201120

1121-
def __str__(self):
1121+
def __unicode__(self):
11221122
return "Notification Check #{}: {}".format(self.id, self.name)
11231123

11241124
@property
@@ -1550,7 +1550,7 @@ class MetricNotificationCheck(models.Model):
15501550
null=True,
15511551
related_name='metric_check')
15521552

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

15971597
self.valid_from, self.valid_to = metric.valid_from, metric.valid_to
15981598

1599-
def __str__(self):
1599+
def __unicode__(self):
16001600
return "MetricValueError({}: metric {} misses {} check: {})".format(self.severity,
16011601
self.metric,
16021602
self.check,

Diff for: requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ django-celery-monitor<=1.1.2
6262
django-celery-beat==1.5.0
6363
django-floppyforms<1.9.0
6464
django-forms-bootstrap<=3.1.0
65-
django-activity-stream==0.8.0
65+
geonode-django-activity-stream==0.9.0
6666
django-autocomplete-light<3.0.0
6767
django-basic-authentication-decorator==0.9
6868
django-leaflet==0.25.0

0 commit comments

Comments
 (0)