Unverified Commit aa0377b0 by Calen Pennington Committed by GitHub

Merge pull request #16661 from cpennington/fix-linting-errors

Fix linting errors from https://github.com/edx/edx-platform/pull/16615
parents c23b0fce 48abc492
......@@ -1760,7 +1760,7 @@ class CourseEnrollment(models.Model):
return None
try:
if not self.schedule or not self.schedule.active:
if not self.schedule or not self.schedule.active: # pylint: disable=no-member
return None
log.debug(
......
......@@ -12,7 +12,7 @@ from collections import defaultdict
from contextlib import contextmanager
from uuid import uuid4
from factory import Factory, Sequence, lazy_attribute_sequence, lazy_attribute, Faker
from factory import Factory, Sequence, lazy_attribute_sequence, lazy_attribute
from factory.errors import CyclicDefinitionError
from mock import patch
from nose.tools import assert_less_equal, assert_greater_equal
......
......@@ -5,6 +5,7 @@ from django import forms
from django.db.models import F
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
from openedx.core.djangolib.markup import HTML
from . import models
......@@ -84,7 +85,7 @@ class ScheduleAdmin(admin.ModelAdmin):
experience_display.short_descriptions = _('Experience')
def username(self, obj):
return '<a href="{}">{}</a>'.format(
return HTML('<a href="{}">{}</a>').format(
reverse("admin:auth_user_change", args=(obj.enrollment.user.id,)),
obj.enrollment.user.username
)
......@@ -93,7 +94,7 @@ class ScheduleAdmin(admin.ModelAdmin):
username.short_description = _('Username')
def course_id(self, obj):
return '<a href="{}">{}</a>'.format(
return HTML('<a href="{}">{}</a>').format(
reverse("admin:course_overviews_courseoverview_change", args=(
obj.enrollment.course_id,
)),
......
"""
A managment command that can be used to set up Schedules with various configurations for testing.
"""
import datetime
import pytz
import factory
from django.core.management.base import BaseCommand
from student.models import CourseEnrollment
from django.contrib.sites.models import Site
from openedx.core.djangoapps.schedules.models import Schedule, ScheduleConfig, ScheduleExperience
from openedx.core.djangoapps.schedules.tests.factories import ScheduleFactory, ScheduleConfigFactory, ScheduleExperienceFactory
from student.tests.factories import CourseEnrollmentFactory
from openedx.core.djangoapps.schedules.models import ScheduleExperience
from openedx.core.djangoapps.schedules.tests.factories import (
ScheduleFactory, ScheduleConfigFactory, ScheduleExperienceFactory
)
from xmodule.modulestore.tests.factories import CourseFactory, XMODULE_FACTORY_LOCK
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from xmodule.modulestore.django import modulestore
class ThreeDayNudgeSchedule(ScheduleFactory):
"""
A ScheduleFactory that creates a Schedule set up for a 3-day nudge email.
"""
start = factory.Faker('date_time_between', start_date='-3d', end_date='-3d', tzinfo=pytz.UTC)
class TenDayNudgeSchedule(ScheduleFactory):
"""
A ScheduleFactory that creates a Schedule set up for a 10-day nudge email.
"""
start = factory.Faker('date_time_between', start_date='-10d', end_date='-10d', tzinfo=pytz.UTC)
class UpgradeReminderSchedule(ScheduleFactory):
"""
A ScheduleFactory that creates a Schedule set up for a 2-days-remaining upgrade reminder.
"""
start = factory.Faker('past_datetime', tzinfo=pytz.UTC)
upgrade_deadline = factory.Faker('date_time_between', start_date='+2d', end_date='+2d', tzinfo=pytz.UTC)
class ContentHighlightSchedule(ScheduleFactory):
"""
A ScheduleFactory that creates a Schedule set up for a course highlights email.
"""
start = factory.Faker('date_time_between', start_date='-7d', end_date='-7d', tzinfo=pytz.UTC)
experience = factory.RelatedFactory(ScheduleExperienceFactory, 'schedule', experience_type=ScheduleExperience.EXPERIENCES.course_updates)
......@@ -45,8 +61,8 @@ class Command(BaseCommand):
max_org_sequence_id = max(int(course.org[4:]) for course in courses if course.org.startswith('org.'))
XMODULE_FACTORY_LOCK.enable()
CourseFactory.reset_sequence(max_org_sequence_id + 1, force=True)
course = CourseFactory(
CourseFactory.reset_sequence(max_org_sequence_id + 1, force=True) # pylint: disable=no-member
course = CourseFactory.create(
start=datetime.datetime.today() - datetime.timedelta(days=30),
end=datetime.datetime.today() + datetime.timedelta(days=30),
number=factory.Sequence('schedules_test_course_{}'.format),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment