|
1 | 1 | import StringIO
|
2 | 2 |
|
3 |
| -from fabric.api import env, put, roles, runs_once, sudo, task |
| 3 | +from fabric.api import env, put, roles, runs_once, settings, sudo, task |
4 | 4 | from fabric.operations import prompt
|
5 | 5 | from fabric.tasks import execute
|
6 | 6 |
|
|
14 | 14 |
|
15 | 15 | APPLICATIONS = ['static', 'frontend']
|
16 | 16 | CAMPAIGN_CLASSES = ['red', 'black', 'green']
|
| 17 | +TEMPLATES = [ |
| 18 | + 'wrapper.html.erb', |
| 19 | + 'homepage.html.erb', |
| 20 | + 'header_footer_only.html.erb', |
| 21 | + 'core_layout.html.erb', |
| 22 | +] |
17 | 23 |
|
18 | 24 |
|
19 | 25 | def validate_classes(campaign_class):
|
@@ -70,8 +76,13 @@ def clear_static_generated_templates():
|
70 | 76 | This function clears the public/template directory to force it to
|
71 | 77 | be regenerated to include the emergency campaign.
|
72 | 78 | """
|
73 |
| - for template in ('wrapper.html.erb', 'header_footer_only.html.erb', 'core_layout.html.erb'): |
74 |
| - sudo('rm /var/apps/static/public/templates/{}'.format(template)) |
| 79 | + for template in TEMPLATES: |
| 80 | + with settings(warn_only=True): |
| 81 | + sudo('rm /var/apps/static/public/templates/{}'.format(template)) |
| 82 | + |
| 83 | + |
| 84 | +def clear_frontend_cache(): |
| 85 | + sudo("rm -rf /var/apps/frontend/tmp/cache/*") |
75 | 86 |
|
76 | 87 |
|
77 | 88 | def deploy_banner(application):
|
@@ -117,3 +128,13 @@ def remove_emergency_banner():
|
117 | 128 | """Remove all banners from GOV.UK"""
|
118 | 129 | for application in APPLICATIONS:
|
119 | 130 | remove_banner(application)
|
| 131 | + |
| 132 | + |
| 133 | +@task |
| 134 | +@roles('class-frontend') |
| 135 | +def clear_cached_templates(): |
| 136 | + for application in APPLICATIONS: |
| 137 | + if application == 'frontend': |
| 138 | + clear_frontend_cache() |
| 139 | + if application == 'static': |
| 140 | + clear_static_generated_templates() |
0 commit comments