From 142539f4988b4d7bf8f37964d9eb9f71990318c3 Mon Sep 17 00:00:00 2001 From: tu-nv Date: Fri, 15 Feb 2019 17:49:12 +0900 Subject: [PATCH] Bump version to 0.7.0 Fix getting template in Hawthorn --- setup.py | 13 +++++++------ submit_and_compare/submit_and_compare.py | 10 ++++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/setup.py b/setup.py index e46bb66..6f2bd2c 100644 --- a/setup.py +++ b/setup.py @@ -11,12 +11,13 @@ from setuptools import setup from setuptools.command.test import test as TestCommand -def package_data(pkg, root): +def package_data(pkg, roots): """Generic function to find package_data for `pkg` under `root`.""" data = [] - for dirname, _, files in os.walk(os.path.join(pkg, root)): - for fname in files: - data.append(os.path.relpath(os.path.join(dirname, fname), pkg)) + for root in roots: + for dirname, _, files in os.walk(os.path.join(pkg, root)): + for fname in files: + data.append(os.path.relpath(os.path.join(dirname, fname), pkg)) return {pkg: data} @@ -45,7 +46,7 @@ def run_tests(self): setup( name='xblock-submit-and-compare', - version='0.6.2', + version='0.7.0', description='Submit and Compare XBlock for self assessment', packages=[ 'submit_and_compare', @@ -70,7 +71,7 @@ def run_tests(self): package_dir={ 'submit_and_compare': 'submit_and_compare', }, - package_data=package_data("submit_and_compare", "static"), + package_data=package_data("submit_and_compare", ['static', 'templates']), classifiers=[ # https://pypi.python.org/pypi?%3Aaction=list_classifiers 'Intended Audience :: Developers', diff --git a/submit_and_compare/submit_and_compare.py b/submit_and_compare/submit_and_compare.py index 515c263..e979311 100644 --- a/submit_and_compare/submit_and_compare.py +++ b/submit_and_compare/submit_and_compare.py @@ -11,17 +11,19 @@ from lxml import etree from django.template import Context, Template -from django.template.loader import get_template from django.utils.translation import ungettext from xblock.core import XBlock from xblock.fields import Scope, String, List, Float, Integer from xblock.fragment import Fragment +from xblockutils.resources import ResourceLoader from .mixins import EnforceDueDates LOG = logging.getLogger(__name__) +loader = ResourceLoader(__name__) + # Public def get_body(xmlstring): @@ -245,9 +247,9 @@ def student_view(self, context=None): 'is_past_due': self.is_past_due(), } ) - template = get_template('submit_and_compare_view.html') - fragment = self.build_fragment( - template, + fragment = Fragment() + fragment.content = loader.render_template( + 'templates/submit_and_compare_view.html', context ) fragment.add_css(