Skip to content

Commit

Permalink
Merge ba79ba1 into f7c4b7f
Browse files Browse the repository at this point in the history
  • Loading branch information
edx-requirements-bot committed Jan 12, 2021
2 parents f7c4b7f + ba79ba1 commit 5b8f3fc
Show file tree
Hide file tree
Showing 21 changed files with 69 additions and 114 deletions.
19 changes: 9 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@ language: python

cache: pip
python:
- 3.5
- 3.8
- '3.8'
env:
- TOXENV=django22
- TOXENV=quality

# Set Travis builds to use docker container
- TOXENV=quality
- TOXENV=django22
- TOXENV=django30
- TOXENV=django31
sudo: false

install:
- make requirements
- pip install tox-travis
- pip install coveralls
- make requirements
- pip install tox-travis
- pip install coveralls

script:
- tox
- tox

after_success: coveralls

Expand Down
5 changes: 2 additions & 3 deletions organizations/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# This Python file uses the following encoding: utf-8
"""
api.py is an interface module for Python-level integration with the
edx-organizations app.
Expand Down Expand Up @@ -112,7 +111,7 @@ def bulk_add_organizations(organization_data_items, dry_run=False, activate=True
_validate_organization_data(organization_data)
if "short_name" not in organization_data:
raise exceptions.InvalidOrganizationException(
"Organization is missing short_name: {}".format(organization_data)
f"Organization is missing short_name: {organization_data}"
)
return data.bulk_create_organizations(
organization_data_items, dry_run=dry_run, activate=activate
Expand Down Expand Up @@ -233,7 +232,7 @@ def bulk_add_organization_courses(
_validate_organization_data(organization_data)
if "short_name" not in organization_data:
raise exceptions.InvalidOrganizationException(
"Organization is missing short_name: {}".format(organization_data)
f"Organization is missing short_name: {organization_data}"
)
_validate_course_key(course_key)
return data.bulk_create_organization_courses(
Expand Down
5 changes: 2 additions & 3 deletions organizations/data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# This Python file uses the following encoding: utf-8
# pylint: disable=expression-not-assigned
"""
Application data management/abstraction layer. Responsible for:
Expand Down Expand Up @@ -410,9 +409,9 @@ def linkage_to_pair(linkage):
}

# Build the same set of pairs for linkages already in the db.
db_linkage_pairs = set(
db_linkage_pairs = {
linkage_to_pair(linkage) for linkage in db_linkages
)
}

# The set of org-course linkages that we must CREATE
# is the set of linkages that were REQUESTED
Expand Down
3 changes: 1 addition & 2 deletions organizations/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# This Python file uses the following encoding: utf-8
"""
Application-specific exception classes used throughout the implementation
"""
Expand All @@ -16,5 +15,5 @@ class InvalidOrganizationException(ValidationError):
def raise_exception(entity_type, entity, exception):
""" Exception helper """
raise exception(
u'The {} you have provided is not valid: {}'.format(entity_type, entity).encode('utf-8')
f'The {entity_type} you have provided is not valid: {entity}'.encode('utf-8')
)
9 changes: 3 additions & 6 deletions organizations/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-


from django.db import models, migrations
import django.utils.timezone
import model_utils.fields
Expand All @@ -18,10 +15,10 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
('name', models.CharField(max_length=255, verbose_name=u'Long name', db_index=True)),
('name', models.CharField(max_length=255, verbose_name='Long name', db_index=True)),
('short_name', models.CharField(max_length=255, db_index=True)),
('description', models.TextField()),
('logo', models.ImageField(help_text='Please add only .PNG files for logo images.', max_length=255, null=True, upload_to=u'organization_logos', blank=True)),
('logo', models.ImageField(help_text='Please add only .PNG files for logo images.', max_length=255, null=True, upload_to='organization_logos', blank=True)),
('active', models.BooleanField(default=True)),
],
options={
Expand All @@ -45,6 +42,6 @@ class Migration(migrations.Migration):
),
migrations.AlterUniqueTogether(
name='organizationcourse',
unique_together=set([('course_id', 'organization')]),
unique_together={('course_id', 'organization')},
),
]
5 changes: 1 addition & 4 deletions organizations/migrations/0002_auto_20170117_1434.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-


from django.db import migrations, models


Expand All @@ -14,6 +11,6 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='organization',
name='logo',
field=models.ImageField(help_text='Please add only .PNG files for logo images. This logo will be used on certificates.', max_length=255, null=True, upload_to=u'organization_logos', blank=True),
field=models.ImageField(help_text='Please add only .PNG files for logo images. This logo will be used on certificates.', max_length=255, null=True, upload_to='organization_logos', blank=True),
),
]
3 changes: 0 additions & 3 deletions organizations/migrations/0003_auto_20170221_1138.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-


from django.db import migrations, models


Expand Down
7 changes: 2 additions & 5 deletions organizations/migrations/0004_auto_20170413_2315.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-


from django.db import migrations, models


Expand All @@ -14,11 +11,11 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='organization',
name='short_name',
field=models.CharField(max_length=255, verbose_name=u'Short Name', db_index=True),
field=models.CharField(max_length=255, verbose_name='Short Name', db_index=True),
),
migrations.AlterField(
model_name='organizationcourse',
name='course_id',
field=models.CharField(max_length=255, verbose_name=u'Course ID', db_index=True),
field=models.CharField(max_length=255, verbose_name='Course ID', db_index=True),
),
]
5 changes: 1 addition & 4 deletions organizations/migrations/0005_auto_20171116_0640.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-


from django.db import migrations, models


Expand All @@ -14,6 +11,6 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='organization',
name='short_name',
field=models.CharField(help_text="Please do not use any spaces or special characters in short name. This short name will be used in the course's course key.", max_length=255, verbose_name=u'Short Name', db_index=True),
field=models.CharField(help_text="Please do not use any spaces or special characters in short name. This short name will be used in the course's course key.", max_length=255, verbose_name='Short Name', db_index=True),
),
]
5 changes: 1 addition & 4 deletions organizations/migrations/0006_auto_20171207_0259.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-


from django.db import migrations, models


Expand All @@ -14,6 +11,6 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='organization',
name='short_name',
field=models.CharField(help_text='Please do not use spaces or special characters. Only allowed special characters are period (.), hyphen (-) and underscore (_).', max_length=255, verbose_name=u'Short Name', db_index=True),
field=models.CharField(help_text='Please do not use spaces or special characters. Only allowed special characters are period (.), hyphen (-) and underscore (_).', max_length=255, verbose_name='Short Name', db_index=True),
),
]
3 changes: 1 addition & 2 deletions organizations/migrations/0007_historicalorganization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-05-31 15:25


Expand All @@ -25,7 +24,7 @@ class Migration(migrations.Migration):
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
('name', models.CharField(db_index=True, max_length=255)),
('short_name', models.CharField(db_index=True, help_text='Please do not use spaces or special characters. Only allowed special characters are period (.), hyphen (-) and underscore (_).', max_length=255, verbose_name=u'Short Name')),
('short_name', models.CharField(db_index=True, help_text='Please do not use spaces or special characters. Only allowed special characters are period (.), hyphen (-) and underscore (_).', max_length=255, verbose_name='Short Name')),
('description', models.TextField(blank=True, null=True)),
('logo', models.TextField(blank=True, help_text='Please add only .PNG files for logo images. This logo will be used on certificates.', max_length=255, null=True)),
('active', models.BooleanField(default=True)),
Expand Down
8 changes: 4 additions & 4 deletions organizations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Organization(TimeStampedModel):
short_name = models.CharField(
max_length=255,
unique=True,
verbose_name=u'Short Name',
verbose_name='Short Name',
help_text=_(
'Unique, short string identifier for organization. '
'Please do not use spaces or special characters. '
Expand All @@ -31,7 +31,7 @@ class Organization(TimeStampedModel):
)
description = models.TextField(null=True, blank=True)
logo = models.ImageField(
upload_to=u'organization_logos',
upload_to='organization_logos',
help_text=_('Please add only .PNG files for logo images. This logo will be used on certificates.'),
null=True, blank=True, max_length=255
)
Expand All @@ -40,7 +40,7 @@ class Organization(TimeStampedModel):
history = HistoricalRecords()

def __str__(self):
return u"{name} ({short_name})".format(name=self.name, short_name=self.short_name)
return f"{self.name} ({self.short_name})"

def clean(self):
if not re.match("^[a-zA-Z0-9._-]*$", self.short_name):
Expand All @@ -56,7 +56,7 @@ class OrganizationCourse(TimeStampedModel):
(in the Django/ORM sense) the modeling and integrity is limited to that
of specifying course identifier strings in this model.
"""
course_id = models.CharField(max_length=255, db_index=True, verbose_name=u'Course ID')
course_id = models.CharField(max_length=255, db_index=True, verbose_name='Course ID')
organization = models.ForeignKey(Organization, db_index=True, on_delete=models.CASCADE)
active = models.BooleanField(default=True)

Expand Down
12 changes: 6 additions & 6 deletions organizations/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ class Meta:
model = User
django_get_or_create = ('email', 'username')

username = factory.Sequence(u'robot{0}'.format)
email = factory.Sequence(u'robot+test+{0}@edx.org'.format)
username = factory.Sequence('robot{}'.format)
email = factory.Sequence('robot+test+{}@edx.org'.format)
password = factory.PostGenerationMethodCall('set_password', 'test')
first_name = factory.Sequence(u'Robot{0}'.format)
first_name = factory.Sequence('Robot{}'.format)
last_name = 'Test'
is_staff = False
is_active = True
Expand All @@ -29,8 +29,8 @@ class OrganizationFactory(DjangoModelFactory):
class Meta:
model = Organization

name = factory.Sequence(u'organization name {}'.format)
short_name = factory.Sequence(u'name{}'.format)
description = factory.Sequence(u'description{}'.format)
name = factory.Sequence('organization name {}'.format)
short_name = factory.Sequence('name{}'.format)
description = factory.Sequence('description{}'.format)
logo = None
active = True
4 changes: 2 additions & 2 deletions organizations/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def create_organization(index, active=True):
Create an organization.
"""
Organization.objects.create(
short_name='test_org_{}'.format(index),
name='test organization {}'.format(index),
short_name=f'test_org_{index}',
name=f'test organization {index}',
description='test organization description',
active=active
)
Expand Down
1 change: 0 additions & 1 deletion organizations/tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Organizations API Module Test Cases
"""
Expand Down
3 changes: 1 addition & 2 deletions organizations/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding=utf-8
"""
Tests for Organization Model.
"""
Expand All @@ -25,7 +24,7 @@ def test_clean_error(self, invalid_char_list):
consists of special characters or spaces.
"""
for char in invalid_char_list:
self.organization.short_name = 'shortname{}'.format(char)
self.organization.short_name = f'shortname{char}'
self.assertRaises(ValidationError, self.organization.clean)

@ddt.data(
Expand Down
4 changes: 2 additions & 2 deletions organizations/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ def make_organization_data(short_name):
"""
return {
'short_name': short_name,
'name': "Name of {}".format(short_name),
'description': "Description of {}".format(short_name),
'name': f"Name of {short_name}",
'description': f"Description of {short_name}",
}
1 change: 0 additions & 1 deletion organizations/validators.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# This Python file uses the following encoding: utf-8
"""
Validators confirm the integrity of inbound information prior to a data.py handoff
"""
Expand Down
7 changes: 3 additions & 4 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cffi==1.14.4
# via cryptography
chardet==4.0.0
# via requests
cryptography==3.2.1
cryptography==3.3.1
# via pyjwt
django-crum==0.7.9
# via edx-django-utils
Expand Down Expand Up @@ -57,7 +57,7 @@ newrelic==5.24.0.153
# via edx-django-utils
pbr==5.5.1
# via stevedore
pillow==7.2.0
pillow==8.1.0
# via -r requirements/base.in
psutil==5.8.0
# via edx-django-utils
Expand Down Expand Up @@ -91,10 +91,9 @@ six==1.15.0
# edx-opaque-keys
# pyjwkest
# python-dateutil
# stevedore
sqlparse==0.4.1
# via django
stevedore==1.32.0
stevedore==3.3.0
# via
# edx-django-utils
# edx-opaque-keys
Expand Down

0 comments on commit 5b8f3fc

Please sign in to comment.