Dynamically changing my background image in django template from a database - django-templates

This is what I am using to change my background image:
<body id="bg" style="background-image: url( '{% static "polls/images/{{freetradezonedata.imagename}}"%}')">
When I go to my webpage and refresh this is what the console is looking for:
"GET /polls/static/polls/images/%7B%7Bfreetradezonedata.imagename%7D%7D HTTP/1.1" 404 1781
The other substitutions from my database are happening in my html.
Is there a syntax change I can make or as etiing I can modify to make this work?
Should I try a different approach?
I did try using {{MEDIA_URL}}{{freetradezonedata.imagename}} from a different solution which resulted in:
/polls/1/test/background.gif HTTP/1.1" 404 2943
It successfully substituted the image name but totally ignored the media_url portion of the path.
media_url was set to MEDIA_URL = '/polls/static/polls/images/'

looking at other comments it occurred to me that nothing in static is going to have tags replaced. so I tried coding just entering the last potion of my image path to see how it would render. It worked, rendered as /polls/static/polls/images/background.gif HTTP/1.1" 304 0

Related

Rendition report is not used when switching resolution on avplayer (safari 16.3)

I'm developing a LL-HLS feature.
When playing the LL-HLS that I developed in Safari, the EXT-X-RENDITION-REPORT tag does not seem to work when the resoution is changed by ABR.
When changing the resolution, the following request is made.
Request without _HLS_msn and _HLS_part query strings when calling chunklist.m3u8 of different resolutions.
Request including _HLS_msn and _HLS_part query strings after requesting chunklist.m3u8 of 1).
In a hls.js, when changing to a different resolution, it was confiremed that _HLS_msn and _HLS_part query strings were included immediately.
OS: macOS (Ventura 13.2.1)
Browser: Safari 16.3
Chunklist.m3u8
EXT-X-SKIP tag is not used
URL: http://10.60.83.51/cvpr0502/onair_llhls_test0001/chunklist_vfrag2500.stream.m3u8
This URL does not play as s sample.
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-SERVER-CONTROL:CAN-BLOCK-RELOAD=YES,PART-HOLD-BACK=3.000000
#EXT-X-PART-INF:PART-TARGET=1.000000
#EXT-X-TARGETDURATION:3
#EXT-X-MEDIA-SEQUENCE:4
#EXT-X-DISCONTINUITY-SEQUENCE:0
#EXT-X-DATERANGE:ID="nmss-daterange",START-DATE="2023-02-20T08:20:00.474Z"
#EXT-X-MAP:URI="vfrag2500.stream_0_0_0.m4s?type=hls&filetype=.m4s"
#EXT-X-PROGRAM-DATE-TIME:2023-02-20T08:20:13.474Z
#EXT-X-PART:DURATION=1.000000,URI="vfrag2500.stream_1994603194_1676881213474_13_0_4_0.m4v?type=hls&mode=cmaf&filetype=.m4v",INDEPENDENT=YES
#EXT-X-PART:DURATION=1.000000,URI="vfrag2500.stream_1994603194_1676881213474_13_0_4_1.m4v?type=hls&mode=cmaf&filetype=.m4v",INDEPENDENT=YES
#EXT-X-PART:DURATION=1.000000,URI="vfrag2500.stream_1994603194_1676881213474_13_0_4_2.m4v?type=hls&mode=cmaf&filetype=.m4v",INDEPENDENT=YES
#EXTINF:3.000000,
vfrag2500.stream_1994603194_1676881213474_13_0_4.m4v?type=hls&bitrate=287035&filetype=.m4v
#EXT-X-PROGRAM-DATE-TIME:2023-02-20T08:20:16.474Z
#EXT-X-PART:DURATION=1.000000,URI="vfrag2500.stream_3207465476_1676881216474_16_0_5_0.m4v?type=hls&mode=cmaf&filetype=.m4v",INDEPENDENT=YES
#EXT-X-PART:DURATION=1.000000,URI="vfrag2500.stream_3207465476_1676881216474_16_0_5_1.m4v?type=hls&mode=cmaf&filetype=.m4v",INDEPENDENT=YES
#EXT-X-PART:DURATION=1.000000,URI="vfrag2500.stream_3207465476_1676881216474_16_0_5_2.m4v?type=hls&mode=cmaf&filetype=.m4v",INDEPENDENT=YES
#EXTINF:3.000000,
vfrag2500.stream_3207465476_1676881216474_16_0_5.m4v?type=hls&bitrate=345122&filetype=.m4v
#EXT-X-PROGRAM-DATE-TIME:2023-02-20T08:20:19.474Z
#EXT-X-PART:DURATION=1.000000,URI="vfrag2500.stream_3408866808_1676881219474_19_0_6_0.m4v?type=hls&mode=cmaf&filetype=.m4v",INDEPENDENT=YES
#EXT-X-PART:DURATION=1.000000,URI="vfrag2500.stream_3408866808_1676881219474_19_0_6_1.m4v?type=hls&mode=cmaf&filetype=.m4v",INDEPENDENT=YES
#EXT-X-PART:DURATION=1.000000,URI="vfrag2500.stream_3408866808_1676881219474_19_0_6_2.m4v?type=hls&mode=cmaf&filetype=.m4v",INDEPENDENT=YES
#EXTINF:3.000000,
vfrag2500.stream_3408866808_1676881219474_19_0_6.m4v?type=hls&bitrate=277635&filetype=.m4v
#EXT-X-PROGRAM-DATE-TIME:2023-02-20T08:20:22.474Z
#EXT-X-PART:DURATION=1.000000,URI="vfrag2500.stream_562750089_1676881222474_22_0_7_0.m4v?type=hls&mode=cmaf&filetype=.m4v",INDEPENDENT=YES
#EXT-X-PART:DURATION=1.000000,URI="vfrag2500.stream_562750089_1676881222474_22_0_7_1.m4v?type=hls&mode=cmaf&filetype=.m4v",INDEPENDENT=YES
#EXT-X-PRELOAD-HINT:TYPE=PART,URI="vfrag2500.stream_562750089_1676881222474_22_0_7_2.m4v?type=hls&mode=cmaf&filetype=.m4v"
#EXT-X-RENDITION-REPORT:URI="chunklist_vfrag1500.stream.m3u8",LAST-MSN=7,LAST-PART=1
#EXT-X-RENDITION-REPORT:URI="chunklist_vfrag400.stream.m3u8",LAST-MSN=7,LAST-PART=1
#EXT-X-RENDITION-REPORT:URI="chunklist_vfrag100.stream.m3u8",LAST-MSN=7,LAST-PART=1
Network in safari
First chunklist.m3u8 request with different resoltuion
_HLS_msn and _HLS_part query strings not found in URL
enter image description here
Second chunklist.m3u8 request
_HLS_msn=7&_HLS_part=1 query strings included in URL
enter image description here
I tried putting paths in various patterns such as absolute paths and relative paths in the URL property of the EXT-X-RENDITION-REPORT tag, but is didn't work.
Is this the behavior of the EXT-X-RENDITION-REPORT tag? If not, I would be grateful if you could let me know what part needs to be corrected.

Problem with prestashop hook.php and tab.php files

We got an error at the top of some pages: Warning: Invalid argument supplied for foreach() in /public_html/classes/Hook.php on line 491.
I've read that it could be a problem with the foreach loop or arrays, but I don't know php and don't know how to fix it.
In line 491 I find: foreach ($results as $result) {
Another problem is that when I enter a category from the client side, I can't go to the 2nd/3rd/4th/5th page, only one page is displayed and the next ones don't want to load. The error Warning: Invalid argument supplied for foreach() in /public_html/classes/Hook.php on line 491 appears on pages that do not want to load.
I also get an error after enabling debug mode:
PrestaShopBundle\EntityTab.
The association PrestaShopBundle\EntityTab#tabLangs refers to the owning side field PrestaShopBundle\EntityTabLang#tab which does not exist.
I changed:
#ORM\OneToMany(targetEntity="PrestaShopBundle\Entity\TabLang", mappedBy="tab")
to
#ORM\OneToMany(targetEntity="PrestaShopBundle\Entity\TabLang", mappedBy="id")
insrc/PrestaShopBundle/Entity/Tab.php but it doesn't help.
PHP debug info debug info
I managed to solve the problem - I had to change active to m.active in the body of the sql query. Thank you

How to catch white screen or black screen using robotframework or selenium

My project is to catch certain error message that can possibly show on website using robot framework and selenium. such as 400 - 500 error messages.
ex: 404. page not found
But we cannot catch empty page like white screen or black screen.
Is there a way for robot/selenium to tell if the page is just all white or all black ? whith no text visible or any element visible.
Thanks
Just get the source and check any unique text or tag and use it in the place of "application-footer". In my case i used application-footer which is available in my source. So Use this below code to find blank page, this is the workaround I used
${Source}= Get Source
Log ${Source}
${Blank_status} = Run Keyword And Return Status Should Contain ${Source} application-footer
Run Keyword If "${Blank_status}" == "False" FAIL Displayed Empty Page
If you want to Handle Failure in your own way, then instead of FAIL keyword write your own keyword to Handle and call the keyword
Run Keyword If "${Blank_status}" == "False" Error_Handle
*** Keywords ***
Error_Handle
# write your handling code

FPDF Fatal Error

I am trying to test implementation of FPDF. Below is the code I'm testing with, but it keeps giving me the error: "Fatal error: Class 'FPDF' not found in /home4/fwall/public_html/create-press-release.php on line 5". That is the URL to the page I am calling the below code on.
I have verified that the php file for FPDF is being required from the right spot, and it's still happening. Can anyone figure out what's going on?
require(__DIR__.'/fpdf.php'); //The fpdf folder is in my root directory.
//create a FPDF object
$pdf=new FPDF();
//set document properties
$pdf->SetAuthor('Lana Kovacevic');
$pdf->SetTitle('FPDF tutorial');
//set font for the entire document
$pdf->SetFont('Helvetica','B',20);
$pdf->SetTextColor(50,60,100);
//set up a page
$pdf->AddPage('P');
$pdf->SetDisplayMode(real,'default');
//insert an image and make it a link
//$pdf->Image('logo.png',10,20,33,0,' ','http://www.fpdf.org/');
//display the title with a border around it
$pdf->SetXY(50,20);
$pdf->SetDrawColor(50,60,100);
$pdf->Cell(100,10,'FPDF Tutorial',1,0,'C',0);
//Set x and y position for the main text, reduce font size and write content
$pdf->SetXY (10,50);
$pdf->SetFontSize(10);
$pdf->Write(5,'Congratulations! You have generated a PDF.');
//Output the document
$pdf->Output('example1.pdf','I');
This line:
require('http://siteurlredacted.com/fpdf/fpdf.php');
probably won't do what you expect. The request will make the remote server "execute" fpdf.php, returning a blank page, and your script will include an empty file. That is why it doesn't find any class to load.
You should download FPDF and put the file on your filesystem, where it is accesible to your script with no HTTP requests. You can try putting fpdf.php inside your project.
Hope this helps.

Balanced Payments doesn't seem to work with Phonegap

We are not able to call balanced.card.create from a Phonegap application. This is reproduced in a stock Phonegap application here: https://github.com/kevg/phonegap-balanced. Full details are in the README.md on github, but the basic summary is:
For those not familiar with phonegap, the main page that loads is
index.html. This initializes phonegap in index.js. When the device is
ready, we will show a hidden DIV with a button named "Execute
Balanced." When you click this button, app.executeBalanced in index.js
will be called which prompts for the balanced marketplace URI, loads
balanced.js with $.getScript, and then calls balanced.card.create with
a test credit card.
The expected result is that callbackHandler is called or an exception
is caught. Instead, it seems the execution of the Javascript thread
disappears into balanced.card.create, never to return and without any
error.
Alrighty, I found the bug in balanced.js. So, in Phonegap, window.location.href returns something like file:///.../index.html. Balanced.js creates an iframe to something like https://js.balancedpayments.com/proxy#file
var src = proxy + "#" + encodeURIComponent(window.location.href);
https://github.com/balanced/balanced-js/blob/master/src/utils.js#L48
In the script returned in proxy.html (which I can't find on github), it does:
c.parentURL=decodeURIComponent(
window.location.hash.replace(/^#/,"")
).replace(/#.*$/,"")
c.parentDomain=c.parentURL.replace(/([^:]+:\/\/[^\/]+).*/,"$1")
The regex doesn't match because file: has three slashes. Now, at first, I thought I could just convert the regex to:
/([^:]+:\/+[^\/]+).*/
However, then there's another problem, because balanced does a security origin check on the match:
if (d.origin.toLowerCase() !== c.toLowerCase()) return !1;
However, the regex returns file:///firstcomponent, whereas event.origin does not include a host name for the file scheme, so these won't match even with a fixed regex.
I can't change anything in the script returned in the proxy response because if I load that from a domain other than balancedpayments.com, then the AJAX POST fails (return code 0 with a blank body). Therefore, the only thing I can control is the hash passed to the iframe.
However, since this regex is a replace, we can simply pass exactly what we know we need (we don't care that the regex is a no-op).
Therefore, the solution is to change L48 above to:
var src = proxy + "#" + encodeURIComponent("file://");
This works.