Commit dfc46050 by Michael LoTurco

Add truncation for too-long offernames

Learner-3936
parent 0dc818b0
......@@ -4,15 +4,13 @@ from __future__ import unicode_literals
import logging
import waffle
from django.conf import settings
from django.core.cache import cache
from edx_rest_api_client.client import EdxRestApiClient
from edx_rest_api_client.exceptions import HttpNotFoundError
from oscar.apps.order.utils import OrderCreator as OscarOrderCreator
from oscar.core.loading import get_model
from requests.exceptions import ConnectionError, ConnectTimeout # pylint: disable=ungrouped-imports
from requests.exceptions import ConnectionError, ConnectTimeout # pylint: disable=ungrouped-imports
from threadlocals.threadlocals import get_current_request
from ecommerce.core.url_utils import get_lms_entitlement_api_url
......
......@@ -88,6 +88,9 @@ class ProgramOfferForm(forms.ModelForm):
program_type=program['type']
))
# Truncate offer_names down to 128 characters, as Oscar's AbstractConditionalOffer name is max_length 128
offer_name = (offer_name[:125] + '...') if len(offer_name) > 128 else offer_name # pylint: disable=unsubscriptable-object
self.instance.name = offer_name
self.instance.status = ConditionalOffer.OPEN
self.instance.offer_type = ConditionalOffer.SITE
......
......@@ -13,7 +13,6 @@ from oscar.core.loading import get_model
from ecommerce.core.models import SiteConfiguration
from ecommerce.theming.models import SiteTheme
logger = logging.getLogger(__name__)
Partner = get_model('partner', 'Partner')
......
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