Skip to content

Commit f73ed98

Browse files
authored
Fixes bugs in grants page (frontend & backend) (#8361)
1 parent f045f06 commit f73ed98

2 files changed

Lines changed: 21 additions & 24 deletions

File tree

app/assets/v2/js/grants/index.js

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,25 @@ let grantsNumPages = '';
22
let grantsHasNext = false;
33
let numGrants = '';
44

5-
let toggleStyle;
5+
const toggleStyle = function(style) {
6+
let banner;
7+
8+
if (style.bg) {
9+
banner = `url("${style.bg }") center top / ${style.size || ''} ${style.color || ''} no-repeat`;
10+
} else {
11+
banner = `url("${ style.banner_image }") center no-repeat`;
12+
}
13+
$('#grant-hero-img').css('background', banner);
14+
if (style.background_image) {
15+
$('#grant-background-image-mount-point').css('background-image', style.background_image);
16+
}
17+
18+
if (style.inline_css) {
19+
$('style').last().text(style.inline_css);
20+
} else {
21+
$('style').last().text('');
22+
}
23+
};
624

725
$(document).ready(() => {
826
$('#sort_option').select2({
@@ -52,28 +70,7 @@ $(document).ready(() => {
5270

5371
});
5472

55-
toggleStyle = function(style) {
56-
let banner;
57-
58-
if (style.bg) {
59-
banner = `url("${style.bg }") center top / ${style.size || ''} ${style.color || ''} no-repeat`;
60-
} else {
61-
banner = `url("${ style.banner_image }") center no-repeat`;
62-
}
63-
$('#grant-hero-img').css('background', banner);
64-
if (style.background_image) {
65-
$('#grant-background-image-mount-point').css('background-image', style.background_image);
66-
}
67-
68-
if (style.inline_css) {
69-
$('style').last().text(style.inline_css);
70-
} else {
71-
$('style').last().text('');
72-
}
73-
74-
};
7573
toggleStyle(document.current_style);
76-
7774
});
7875

7976
Vue.component('grant-sidebar', {

app/grants/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,8 +827,8 @@ def get_bg(grant_type):
827827
def get_policy_state(policy, request):
828828
return {
829829
"url_pattern": policy.url_pattern,
830-
"banner_image": request.build_absolute_uri(policy.banner_image.url) if policy.banner_image else None,
831-
"background_image": request.build_absolute_uri(policy.background_image.url) if policy.background_image else None,
830+
"banner_image": request.build_absolute_uri(policy.banner_image.url) if policy.banner_image else '',
831+
"background_image": request.build_absolute_uri(policy.background_image.url) if policy.background_image else '',
832832
"inline_css": policy.inline_css
833833
}
834834

0 commit comments

Comments
 (0)