本文整理汇总了Python中demos.models.Submission.censor方法的典型用法代码示例。如果您正苦于以下问题:Python Submission.censor方法的具体用法?Python Submission.censor怎么用?Python Submission.censor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类demos.models.Submission
的用法示例。
在下文中一共展示了Submission.censor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_censored_demo_files_are_deleted
# 需要导入模块: from demos.models import Submission [as 别名]
# 或者: from demos.models.Submission import censor [as 别名]
def test_censored_demo_files_are_deleted(self):
"""Demo files should be deleted when the demo is censored."""
fout = StringIO()
zf = zipfile.ZipFile(fout, 'w')
zf.writestr('demo.html', """<html></html""")
zf.writestr('css/main.css', 'h1 { color: red }')
zf.writestr('js/main.js', 'alert("HELLO WORLD");')
zf.close()
s = Submission(title='Hello world', slug='hello-world',
description='This is a hello world demo',
creator=self.user)
s.demo_package.save('play_demo.zip', ContentFile(fout.getvalue()))
s.demo_package.close()
s.clean()
s.save()
s.process_demo_package()
path = s.demo_package.path.replace('.zip', '')
ok_(isdir(path))
ok_(isfile(s.demo_package.path))
ok_(isfile('%s/index.html' % path))
ok_(isfile('%s/css/main.css' % path))
ok_(isfile('%s/js/main.js' % path))
s.censor(url="http://example.com/censored-explanation")
ok_(not isfile(s.demo_package.path))
ok_(not isfile('%s/index.html' % path))
ok_(not isfile('%s/css/main.css' % path))
ok_(not isfile('%s/js/main.js' % path))
ok_(not isdir(path))