Skip to content
This repository has been archived by the owner on Mar 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #10 from natgeosociety/python3
Browse files Browse the repository at this point in the history
Python3 Upgrade
  • Loading branch information
akandada authored Feb 28, 2020
2 parents 7baa55e + 2fc974b commit 9eb03f7
Show file tree
Hide file tree
Showing 26 changed files with 79 additions and 85 deletions.
6 changes: 3 additions & 3 deletions curricula/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
django-lessons
"""
__version_info__ = {
'major': 2,
'minor': 9,
'micro': 2,
'major': 3,
'minor': 0,
'micro': 0,
'releaselevel': 'final',
'serial': 1,
}
Expand Down
12 changes: 6 additions & 6 deletions curricula/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.conf import settings
from django.contrib import admin
from django.contrib.contenttypes.models import ContentType
from django.utils.encoding import force_unicode
from django.utils.encoding import force_text
from django.utils.html import strip_tags
from django.utils.html import escape, conditional_escape

Expand Down Expand Up @@ -135,23 +135,23 @@ def get_title(self, obj):

class StandardsWidget(admin.widgets.FilteredSelectMultiple):
def render_option(self, selected_choices, option_value, option_label):
option_value = force_unicode(option_value)
option_value = force_text(option_value)
if option_value in selected_choices:
selected_html = u' selected="selected"'
selected_html = ' selected="selected"'
if not self.allow_multiple_selected:
# Only allow for a single selection.
selected_choices.remove(option_value)
else:
selected_html = ''

standard = Standard.objects.get(pk=option_value)
title = u"%s: %s: %s" % (standard.get_standard_type_display(),
title = "%s: %s: %s" % (standard.get_standard_type_display(),
standard.name,
strip_tags(standard.definition))

return u'<option value="%s" title="%s"%s>%s</option>' % (
return '<option value="%s" title="%s"%s>%s</option>' % (
escape(option_value), title, selected_html,
conditional_escape(force_unicode(option_label)))
conditional_escape(force_text(option_label)))


class SkillAdmin(admin.ModelAdmin):
Expand Down
4 changes: 2 additions & 2 deletions curricula/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


from django.db import models, migrations
import bitfield.models
Expand All @@ -19,7 +19,7 @@ class Migration(migrations.Migration):
('reference', '0001_initial'),
('resource_carousel', '0001_initial'),
('contenttypes', '0001_initial'),
('edumetadata', '0001_initial'),
('edumetadata', '0001_squashed_0003_change_array_field_type'),
]

operations = [
Expand Down
2 changes: 1 addition & 1 deletion curricula/migrations/0002_auto_20150423_1159.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


from django.db import models, migrations

Expand Down
2 changes: 1 addition & 1 deletion curricula/migrations/0003_add_archived.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


from django.db import models, migrations

Expand Down
2 changes: 1 addition & 1 deletion curricula/migrations/0004_change_prior_knowledge.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


from django.db import migrations
from curricula.utils import ul_as_list
Expand Down
2 changes: 1 addition & 1 deletion curricula/migrations/0005_auto_20161202_1211.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.11 on 2016-12-02 17:11
from __future__ import unicode_literals


from django.db import migrations, models
import taxonomy.managers
Expand Down
2 changes: 1 addition & 1 deletion curricula/migrations/0006_add_categoryidea_ordering.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.11 on 2017-03-14 19:18
from __future__ import unicode_literals


from django.db import migrations, models

Expand Down
2 changes: 1 addition & 1 deletion curricula/migrations/0007_delete_cascade_fix.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2017-06-22 15:52
from __future__ import unicode_literals


from django.db import migrations, models
import django.db.models.deletion
Expand Down
2 changes: 1 addition & 1 deletion curricula/migrations/0008_auto_20190502_1324.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.17 on 2019-05-02 17:24
from __future__ import unicode_literals


import bitfield.models
from django.db import migrations
Expand Down
12 changes: 6 additions & 6 deletions curricula/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from metadata import (GroupingType, LearnerGroup, LearningObjective, # NOQA
from .metadata import (GroupingType, LearnerGroup, LearningObjective, # NOQA
Material, ObjectiveRelation, PhysicalSpaceType, PluginType, Skill,
Standard, TeachingApproach, TeachingMethodType, TechSetupType, Tip,
TipCategory) # NOQA

from activity import Activity, ResourceItem, Vocabulary, QuestionAnswer # NOQA
from lesson import Lesson, LessonActivity # NOQA
from unit import Unit, UnitLesson # NOQA
from idea import IdeaCategory, Idea, CategoryIdea # NOQA
from relations import ActivityRelation, LessonRelation, UnitRelation, IdeaCategoryRelation # NOQA
from .activity import Activity, ResourceItem, Vocabulary, QuestionAnswer # NOQA
from .lesson import Lesson, LessonActivity # NOQA
from .unit import Unit, UnitLesson # NOQA
from .idea import IdeaCategory, Idea, CategoryIdea # NOQA
from .relations import ActivityRelation, LessonRelation, UnitRelation, IdeaCategoryRelation # NOQA
12 changes: 6 additions & 6 deletions curricula/models/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class Activity(models.Model):
def get_absolute_url(self):
return ('activity-detail', (), {'slug': self.slug})

def __unicode__(self):
def __str__(self):
return strip_tags(self.title)

class Meta:
Expand Down Expand Up @@ -282,8 +282,8 @@ class Meta:
verbose_name_plural = 'Vocabulary'
app_label = 'curricula'

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


class QuestionAnswer(models.Model):
Expand All @@ -294,10 +294,10 @@ class QuestionAnswer(models.Model):

class Meta:
app_label = 'curricula'
verbose_name = u'Question and Answer'
verbose_name_plural = u'Questions and Answers'
verbose_name = 'Question and Answer'
verbose_name_plural = 'Questions and Answers'

def __unicode__(self):
def __str__(self):
return truncate(self.question)


Expand Down
6 changes: 3 additions & 3 deletions curricula/models/idea.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Meta:
verbose_name_plural = 'Idea categories'
app_label = 'curricula'

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

@models.permalink
Expand Down Expand Up @@ -195,7 +195,7 @@ class Idea(models.Model):
max_length=256,
null=True)

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

def _get_categories(self):
Expand All @@ -217,7 +217,7 @@ class Meta:
app_label = 'curricula'
ordering = ('order', )

def __unicode__(self):
def __str__(self):
return self.category.title

pre_delete.connect(delete_listener, sender=IdeaCategory)
11 changes: 1 addition & 10 deletions curricula/models/lesson.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,6 @@ def save(self, *args, **kwargs):
self.accessibility_notes = list_as_ul(
list(set(chain(*[ul_as_list(x) for x in agg_activities('accessibility_notes')])))
)
rsd = agg_activities('relevant_start_date')
if rsd:
self.relevant_start_date = min(rsd)
red = agg_activities('relevant_end_date')
if red:
self.relevant_end_date = max(red)
gt = agg_activities('geologic_time')
if gt:
self.geologic_time = min(gt)
self.duration = self._calc_duration(self.activities.all())
super(Lesson, self).save(*args, **kwargs)
self._sync_m2m(self.eras, agg_activities('eras'))
Expand Down Expand Up @@ -216,7 +207,7 @@ def get_absolute_url(self):
def get_canonical_page(self):
return reverse('lesson-detail', args=[self.slug])

def __unicode__(self):
def __str__(self):
return strip_tags(self.title)

if RELATION_MODELS:
Expand Down
23 changes: 12 additions & 11 deletions curricula/models/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from curricula.settings import TIP_TYPE_CHOICES, STANDARD_TYPES
from curricula.utils import truncate
from edumetadata.models import Grade
from functools import reduce

__all__ = (
'GroupingType',
Expand Down Expand Up @@ -39,7 +40,7 @@ class Meta:
ordering = ["name"]
app_label = 'curricula'

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


Expand All @@ -50,7 +51,7 @@ class GroupingType(MetadataBase):
class LearnerGroup(models.Model):
name = models.CharField(max_length=31)

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

class Meta:
Expand All @@ -65,7 +66,7 @@ class Meta:
ordering = ['text']
app_label = 'curricula'

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


Expand All @@ -84,14 +85,14 @@ class ObjectiveRelation(models.Model):
class Meta:
app_label = 'curricula'

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


class Material(models.Model):
name = models.TextField()

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

class Meta:
Expand Down Expand Up @@ -126,7 +127,7 @@ class TeachingMethodType(MetadataBase):
class TechSetupType(models.Model):
title = models.CharField(max_length=64)

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

class Meta:
Expand Down Expand Up @@ -157,9 +158,9 @@ class Meta:
verbose_name_plural = "Tips & Modifications"
app_label = 'curricula'

def __unicode__(self):
def __str__(self):
if self.category:
return u'%s: %s' % (self.category.name,
return '%s: %s' % (self.category.name,
truncate(strip_tags(self.body), 45))
else:
return truncate(strip_tags(self.body), 75)
Expand All @@ -179,8 +180,8 @@ class Standard(models.Model):
when_updated = models.DateTimeField(null=True, blank=True, auto_now=True)
grades = models.ManyToManyField(Grade)

def __unicode__(self):
return u"%s: %s: %s" % (truncate(self.get_standard_type_display(), 54),
def __str__(self):
return "%s: %s: %s" % (truncate(self.get_standard_type_display(), 54),
truncate(self.name, 44),
truncate(strip_tags(self.definition), 54))

Expand Down
25 changes: 13 additions & 12 deletions curricula/models/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.utils.translation import ugettext_lazy as _

from curricula.settings import (RELATIONS, RELATION_TYPES)
from functools import reduce


if RELATIONS:
Expand Down Expand Up @@ -42,39 +43,39 @@ class Meta:
class ActivityRelation(ModelRelation):
activity = models.ForeignKey('curricula.Activity', related_name='relations')

def __unicode__(self):
out = u"%s related to %s" % (self.content_object, self.activity)
def __str__(self):
out = "%s related to %s" % (self.content_object, self.activity)
if self.relation_type:
out += u" as %s" % self.relation_type
out += " as %s" % self.relation_type
return out


class LessonRelation(ModelRelation):
lesson = models.ForeignKey('curricula.Lesson', related_name='relations')

def __unicode__(self):
out = u"%s related to %s" % (self.content_object, self.lesson)
def __str__(self):
out = "%s related to %s" % (self.content_object, self.lesson)
if self.relation_type:
out += u" as %s" % self.relation_type
out += " as %s" % self.relation_type
return out


class UnitRelation(ModelRelation):
unit = models.ForeignKey('curricula.Unit', related_name='relations')

def __unicode__(self):
out = u"%s related to %s" % (self.content_object, self.unit)
def __str__(self):
out = "%s related to %s" % (self.content_object, self.unit)
if self.relation_type:
out += u" as %s" % self.relation_type
out += " as %s" % self.relation_type
return out


class IdeaCategoryRelation(ModelRelation):
idea_category = models.ForeignKey(
'curricula.IdeaCategory', related_name='relations')

def __unicode__(self):
out = u"%s related to %s" % (self.content_object, self.idea_category)
def __str__(self):
out = "%s related to %s" % (self.content_object, self.idea_category)
if self.relation_type:
out += u" as %s" % self.relation_type
out += " as %s" % self.relation_type
return out
3 changes: 2 additions & 1 deletion curricula/models/unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from core_media.models import NGPhoto # NOQA
from credits.models import CreditGroup # NOQA
from taxonomy.managers import TaxonomyTaggableManager
from functools import reduce

__all__ = ('Unit', 'UnitLesson')

Expand Down Expand Up @@ -147,7 +148,7 @@ def _sync_m2m(self, attr, new_set):
if to_remove:
attr.remove(*list(to_remove))

def __unicode__(self):
def __str__(self):
return strip_tags(self.title)

@models.permalink
Expand Down
Loading

0 comments on commit 9eb03f7

Please sign in to comment.