These are chat archives for mirumee/saleor

21st
Feb 2019
jdivins
@jdivins
Feb 21 09:50
Good morning saleors!
We want to make translations for each language at http://127.0.0.1:8000/dashboard/page/add/
in dashboard 1.0
Maybe someone has implemented or tried to implement this feature?
Thank you!
Marcin Gębala
@maarcingebala
Feb 21 09:52
jdivins
@jdivins
Feb 21 10:00
Yes I am talking about model translations. It will be possible to use django templating for frontend and dashboard 2.0 as backend?
Marcin Gębala
@maarcingebala
Feb 21 10:05
Yep, that should be possible. Accessing translated properties is fairly simple e.g. product.translated.name would automatically match the translation based on locale (if given translation is avaiable of course).
jdivins
@jdivins
Feb 21 10:12
In order to bring the user this possibility on dasboard 1.0, what do you think about show all the possible translation fields as a textareas and save or edit all at the same time ?
Its only for a local fork.
jdivins
@jdivins
Feb 21 11:58
Is there a way to save the content of the editor as html format? @maarcingebala ?
Marcin Gębala
@maarcingebala
Feb 21 13:17
The editor that we have now in Dashbaord 1.0 produces the HTML output which is then saved in the database.
What do you mean exactly?
jdivins
@jdivins
Feb 21 13:41

In dashboard 1.0 if I add this HTML code on a page:

<div class="container mt-5 mb-5">
  <div class="row mb-5">
    <div class="col-12">
      <h1 class="blue text-center">Help</h1>
    </div>
  </div>
</div>

On storefront I see the HTML code instead of Help. Is there a way to save as HTML in the database?
In database I see:
<p>&lt;div class="container mt-5 mb-5"&gt;</p><p> &lt;div class="row mb-5"&gt;</p><p> &lt;div class="col-12"&gt;</p><p> &lt;h1 class="blue text-center"&gt;Help&lt;/h1&gt;</p>

Marcin Gębala
@maarcingebala
Feb 21 13:54
You need this in order to make Django template engine actually render the HTML if it comes from the database
jdivins
@jdivins
Feb 21 14:05
After insert HTML on dashboard page edit content field, I don't want to show HTML in storefront, I want that storefront render the HTML saved.
But after save on dashboard the content field it is sotred in database with < symbols. How can I make that content field save HTML insteand of < symbols?
Marcin Gębala
@maarcingebala
Feb 21 14:11
The output of HTML editor are escaped and maybe that's the reason for those symbols? But it does work on master however and it renders HTML properly. About the safe tag - you need to use it in your stofront to render HTML.
jdivins
@jdivins
Feb 21 14:19
Captura de Pantalla 2019-02-21 a les 15.19.05.png Editing dashboard
Captura de Pantalla 2019-02-21 a les 15.18.38.png
with safe
Captura de Pantalla 2019-02-21 a les 15.18.51.png
without safe
And I want to see:
Captura de Pantalla 2019-02-21 a les 15.21.37.png
Marcin Gębala
@maarcingebala
Feb 21 14:22
Basically in the "content" text field you shouldn't see the HTML - there is the editor that allows you to edit styles and you shuold see the styles rendered - it's a WYSIWYG editor. I think that what happend in your case is having a HTML content, that is wrapped in some additional HTML be the editor again. As a result the markup breaks at some point.
jdivins
@jdivins
Feb 21 14:23
Can I insert HTML on the WYSIWYG editor?
Marcin Gębala
@maarcingebala
Feb 21 14:23
No, the one we're using unfortunately doesn't support that :(
jdivins
@jdivins
Feb 21 14:24
Ok! Can I replace the field for a textarea field?
Marcin Gębala
@maarcingebala
Feb 21 14:27
In what sense "replace"? :)
jdivins
@jdivins
Feb 21 14:29
intead of render on dashboard the field as medium editor, use a simple textarea that doesn't replace html format
Marcin Gębala
@maarcingebala
Feb 21 14:30
Sure, you can disable that. AS far as I remember there is some JS that enables the Medium editor over there
I don't remember now exactly where it sits, let me know if you have troubles with finding that
jdivins
@jdivins
Feb 21 14:45
If you could point me in the correct direction or file, will be helpfully
Marcin Gębala
@maarcingebala
Feb 21 15:10
You can disable that from Python as well - there is RichTextField form field that we're using to enable medium editor. Underneath it uses RichTextEditorWidget. Chaning to regular CharField / Textarea widget would disable the editor.
jdivins
@jdivins
Feb 21 15:22
Ok! Thank you very much for you appointment
James
@Xtrasalty_gitlab
Feb 21 17:05
Hello
I am trying to add a custom text field when somone adds an item to cart. Any pointers how how to actually send the value with the POST data?
I tried to add a text input inside the form that holds variant data and quantity but it doesnt pass. I am assuming there is some JS magic that happens and thats where I am losing it?
James
@Xtrasalty_gitlab
Feb 21 17:12
I printed the POST data in
add_product_to_cart and i see variant and quantity
xtrasalty
@xtrasalty
Feb 21 23:11
Still had no luck. I noticed when adding a line to the cart there is a ‘data’ dictionary and if that is different it will create a separate line. Is there a way to add a custom text in that data dictionary from the product details template?