css.py 446 B

123456789101112131415161718192021
  1. from .utils import get_file_hash
  2. def create_css(theme, css):
  3. if css_exists(theme, css):
  4. delete_css(theme, css)
  5. save_css(theme, css)
  6. def css_exists(theme, css):
  7. return theme.css.filter(name=css.name).exists()
  8. def delete_css(theme, css):
  9. theme.css.get(name=css.name).delete()
  10. def save_css(theme, css):
  11. theme.css.create(
  12. name=css.name, source_file=css, source_hash=get_file_hash(css), size=css.size
  13. )