Is there a way to filter the Document chooser when it's opened from a particular block's form? [duplicate] - wagtail

This question already has answers here:
Limiting file types for a specific DocumentChooserBlock() Block in Wagtail Steamfield
(2 answers)
Closed 1 year ago.
I'm writing a custom StreamBlock that is designed to render a table based on the data in a given CSV file. The CSV files will be stored in the usual Document store, so the block needs to present the Document chooser to let the user pick a CSV file.
I would like to restrict this block's Document chooser to documents whose filenames end in .csv, without affecting any other Document chooser. I dug into the code to try to figure out a way to do that, but after 30 minutes of poking around, it doesn't look like there's any obvious way to determine the source of a request to the admin/documents/chooser/ view, which is what actually renders the Document listing.
My best guess at the moment for how to do this would be to subclass DocumentChooserBlock and AdminDocumentChooser, so that I can tell it to use a custom version of wagtaildocs/js/document-chooser-modal.js. I'd change it to send an extra GET argument, or something like that, whenever CSVTableBlock's Document chooser sends a request to admin/documents/chooser/. Then I could implement construct_document_chooser_queryset to look for that custom GET arg, so it knows when to filter the documents queryset to only .csv files.
But I'm really not at all sure that this is the right way to go about it, or if it's even possible for that strategy to work. Is there a better/possible way to do this?

you actually no need to do anything, almost all use cases for such filtering scenarios, an editor can input the ".csv" in the search box of the chooser modal

Related

Can't find a referenced R File on the SEC Website?

I am attempting to understand the 2020q1 data set found here: https://www.sec.gov/dera/data/financial-statement-data-sets.html,
and am using the reference documentation inside the 2020q1 folder as a “readme” file. The reference documentation specifies that
within the Presentation (pre) data set, the “report” field is a numeric (integer) whose “value refers to the “R file” as posted
on the EDGAR Web site.” I have found no such file after extensive search, and am left with no method of interpreting the “report”
field and all associated data. Please link to the appropriate R File or guide me in the right direction for assistance if possible. Thanks!
So a point of clarification upfront, cause this confused me as well, the "R file" in question is not a script file of the R language. Instead, it simply seems to be a report file that holds the formatted data.
So after digging deeper into the readme, I found the following detail in the description for the SUB.txt data.
Note: To access the complete submission files for a given filing, please see the SEC EDGAR website. The SEC website folder HTTP(s)://www.sec.gov/Archives/edgar/data/{cik}/{accession}/ will always contain all the data sets for a given submission. To assemble the folder address to any filing referenced in the SUB data set, simply substitute {cik} with the cik field and replace {accession} with the adsh field (after removing the dash character). The following sample SQL Query provides an example of how to generate a list of addresses for filings contained in the SUB data set:
· select name,form,period, 'http(s)://www.sec.gov/Archives/edgar/data/' + ltrim(str(cik,10))+'/' + replace(adsh,'-','')+'/'+instance as url from SUBM subm order by period desc, name
Therefore, it looks like we have to correlate each "adsh" submission ID with the "cik" company ID in order to get the link we are looking for.
Doing this for the first entry of pre.txt, we get an adsh value of "0001032208-20-000006". I simply searched through sub.txt with notepad and found its associated cik of "1032208" which belongs to "SEMPRA ENERGY". Therefore, we generate the following link: http://www.sec.gov/Archives/edgar/data/1032208/000103220820000006
From there, we find a directory of files associated with the given submission. Inside is a collection of files with the prefix of "R". Simply clicking on them will open them in your browser, using the "report" and "line" fields, we can then correlate which file we want. Notice that we can add "/R{number}.htm" at the end of the link we generated to find this folder to get a given report number.
If you know what you are looking for, doing this by hand with "ctr+f" find functionality should be fine. Otherwise, you may want to open these docs in excel to generate the links for you.

Setting SSRS BackgroundImage Source from field

I'm working on an SSRS template at present which pulls lots of its format information from a database. Part of this format information sets the Background Image of cells.
I'm currently filling the image by setting the Source to External and pulling its value from the database. This works lovely, however It means pulling the image from a network source each time and while a small efficiency hit, I'd like to try and remove that pull if possible by embedding the standard images.
Again this works fine, I can pull either an external image or an embedded image and display on screen. The problem comes when I'd like the option to do either.
I find that I cannot set the image Source from a field, there isn't an option in the GUI.
I've tried going into the code and entering the details there but I get a validation error:
The 'http://scemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition:Source' element is invalid - The value =First(Fields!bodyBackgroundImageSource.Value, "dsTemplate") is invalid according to its datatype String - The Enumeration constraint failed".
Has anyone else come across this and found a solution or know of a workaround? I can continue using only external images, but would prefer to avoid as many external calls as possible.
In our local environment, we tested this scenario and if the expression can return the correct image name, then the image can display properly. You can check if the "First(Fields!bodyBackgroundImageSource.Value, "dsTemplate")" expression return the image name existing under Images folder on Report Data window. And make sure the image source is embedded.

drupal theme multiupload image field

I have one drupal content type. there is one image field, the configuration is:
content type field setting
It works fine. I can upload multi image to that content type. The only problem is that, the uploaded image is themed in table format.
uploaded results
How can i change the output format other than table? I have searched for the whole day, still can not find the answer :(
What I have seen from your given images, you have an image field in your content type. Also I am not sure that in which way you are showing all the images on the front end. This could be done in several ways. One of them is using 'Views'.
Views
So if you are collecting all the images into a view creating a page or block, then you can easily change the showing format. Like you can use the table format and also list format. And on the front end you could be able have a non-tabular format.
Tpl files
On the other hand, if you are using special node tpl then you have to format the html properly so that they won't come in a tabular format.
I will personally suggest you to use the views to avoid unnecessary problems and also you can also specify the view specific tpl file.
Cheers :) keep Drupalizing :)

Torrent file protocol - custom field

I am wondering if there is any available field in the .torrent files that could be used for some custom functionality in someone's implementation of a torrent client? For example, one might want to encode an URL to the file owner's website, someone else - some custom message to be displayed when opening the files, etc. Is something like this feasible in the current implementation of .torrent files?
Yes. .torrent files are just bencoded dictionaries and can hold arbitrary key-value pairs.
The main consideration when adding a custom field is to determine whether it should go into the root of the .torrent or inside the info dictionary.
If it goes into the root, it will not affect the info hash (which is the unique identifier of the torrent), and it will also not be available when downloading magnet links.
If it goes into the info dictionary, it is sort of locked down to the info-hash, in the sense that the info-hash depends on it. It will be transferred as part of the metadata when downloading magnet links and it cannot be changed (without changing the info-hash and thus creating a separate swarm).
So, if it's something you want 3rd parties should be able to change after the torrent was created, it should go in the root, if you want it to be entered once when the torrent is created and never change, it should go in the info dict.

Receive multi file post with google app engine

I want to receive multi file post from image uploader.(i use this)
Most examples show how to receive one image from post.
I tried many ways but never got the results.
For example
self.request.POST['Filename']
gives only first filename.
What to do when there are multiple files/images in post?
The reason for this is to resize before upload images, that are too big for google app engine
to upload.
EDIT:
self.request.POST.multi.__dict__
shows
{'_items':
[('Filename', 'camila1.jpg'),
('Filedata[]', FieldStorage('Filedata[]', 'camila1.jpg')),
('Upload', 'Submit Query\r\n--negpwjpcenudkacqrxpleuuubfqqftwm----negpwjpcenudkacqrxpleuuubfqqftwm\r\nContent-Disposition: form-data; name="Filename"\r\n\r\nbornToBeWild1.jpg'),
('Filedata[]', FieldStorage('Filedata[]', 'bornToBeWild1.jpg')),
('Upload', 'Submit Query')]}
Your flash uploader is designed to work with PHP and sends multiple Filedata[] fields (php interprets this as an array for easy access)
So you need to iterate and get them all:
def post(self):
for file_data in self.request.POST.getall('Filedata[]'):
logging.info(file_data.filename)
data should be file_data.value
Are you using the Django libraries available to you? If so, check this out.
Call self.request.POST.getall('Filename') to get a list of FieldStorage objects; each one contains one file. You can access the file data with .value, the name with .name, and the mimetype with .type.
I have no idea how that multi uploader works, I have made one in the past however and I just added a number on the end of input field name, then hide it. Then add a new file input field to add another file. The reason for this is that they don't let you play around with input file fields to much because you could make it upload files they didn't want you uploading.
Using my conventions, in your example the 2 files in your example would be "Filename0" and "Filename1". You could also use firebug to see what it renaming the input file fields to.
Edit: I had a look, and it's using flash. So i have no idea how it works.

Resources