prestashop 1.7 update order custom field using webservice - web-services

I'm working on Prestashop 1.7.7.4. I've created a custom boolean field on ps_orders table and overridden Order model definition and webserviceParameters to add such field.
Now when I GET an order through webservice I fetch the field and I can use it as a filter.
Unfortunately I can't PUT such field through webservice. I noticed that such issue was already reported on prestashop issue tracker but it was closed.
So I'm wondering if anyone could address me to the solution or at least to a way to look into the right code to find the problem.
Thanks in advance for your kind answers.

Related

How to check duplicate posts when submitting a new post in Django admin?

I have coworkers to upload posts through Django admin. The problem is they keep making duplicate posts as we've been covering a lot of posts. Is there a way to find out if a post already exists when typing a certain column or submitting?
I searched about that, but didn't get any useful information.
Your business case seems to be a text that is duplicate if it is case sensitive equal.
On a DB and Django Model level you assure unique entries by adding unique:
class MyModel(Model):
my_field = TextField(unique=True)
To check during input you need JavaScript in the client and an AJAX endpoint on the Django server side. It's actually an Autocomplete/Autosuggest functionality for that field. There are several packages that might help you with that. Out of the box, the Django Admin does not support this.

Django Rest Framework Hyperlinked Fields Understanding

I can't seem to grasp the difference between HyperlinkedIdentity and HyperlinkedRelated Fields. I have a few questions that I can't seem to find the answers to online.
What is the actual difference? When would I want to use one vs. the other.
My next question is say I have 2 models, Project and Task.
A Task has a ForeignKey to Project. If I wanted the Project to hyperlink to the tasks within it, which Hyperlink field would I put in the ProjectSerializer? And what field would I put in the TaskSerializer to complement the ProjectSerializer assuming I wanted the tasks to be able to hyperlink back to the Project they are related to?
What is the difference between using the hyperlinked fields vs. just using regular nested serializers? When using hyperlinked fields, can I still filter by pk/id?
Last, What if a model had two hyperlinked relations in the serializer? From what I understand it creates a url field for each hyperlink, would it create two url fields in this case?
Thanks for any clarification you can offer, it will be a huge help towards cementing my understanding on the subject and allowing me to complete my API for my project.
What is the actual difference? When would I want to use one vs. the other.
HyperlinkedIdentityField is an hyperlink field for the current object itself while HyperlinkedRelatedField represent an hyperlink to other instances.
A Task has a ForeignKey to Project. If I wanted the Project to hyperlink to the tasks within it, which Hyperlink field would I put in the ProjectSerializer? And what field would I put in the TaskSerializer to complement the ProjectSerializer assuming I wanted the tasks to be able to hyperlink back to the Project they are related to?
HyperlinkedRelatedField is what you're looking for.
What is the difference between using the hyperlinked fields vs. just using regular nested serializers?
Hyperlinks can be browsed independently from the original resource. Handy if one of them belongs to another system. For example, you'll likely want to use hyperlink to tweets rather than let your server fetch them and them return them nested. Hyperlinks also allows the client to deal with its own caching rather than sending back all the data. Could be handy in case of fetching a list of items that nest the same user.
On the other hand, hyperlinks increase the network request count because it needs to fetch more data.
When using hyperlinked fields, can I still filter by pk/id?
Not sure what you mean here.
What if a model had two hyperlinked relations in the serializer? From what I understand it creates a url field for each hyperlink, would it create two url fields in this case?
Correct. hyperlinked relation are just a representation of a relation. It provides an hyperlink (an uri) to fetch the associated object.
This is useful because you won't need to know the pattern to fetch an object from the id: with a PrimaryKeyRelatedField you'll get the id but are missing the url to fetch the associated object.
This also allows the server to manage its own uri space without the need of updating the clients.
Hope this will help.

Django Model generalized condition

How can I add a generalized condition in django models like if I filter using ORM object the condition should automatically get added.
I have done similar in cake PHP and YII where I actually get the query ORM and I can add a condition that gets attached to the query and later the query is fired.
Looking for similar kind of function in Django for Users Model.
User.objects.filter(date_joined__range=(start_date_time, end_date_time))
I want whenever I filter using this it should add a condition to the query.
Answers and suggestions would be appreciated.

Autocomplete field in Web Forms for Marketers and custom Field validator

I am using WFFM in Sitecore 7.1 , one of the requirement to have a field named Countries and want to use it as autocomplete field.
I have already loaded all the Countries in Sitecore as Sitecore Object.
I was following the Custom Credit card field , but it didn't help much.
I created custom autocomplete Field in WFFM and now i want to create custom validation for this field .
Any help..
Thanks
To keep it simple you might want to consider a custom control like credit card and use client side JS to call your countries via sitecore web API and then do all the auto complete stuff in the js leaving all logic there.
If server side code is a preference then u can write a web service to return you the JSON objects of matching countries making your JS more simpler.
Hope this can help with some ideas.

How can you get future-dated posts in Django?

I just want to do a basic site in Django and the flatpages app is super simple, but it doesn't support a couple of things that I need, namely custom fields and future-dating. That is setting a publish date to some point in the future rather than publishing immediately.
What's the best option for getting future-dated posts in Django?
The answer to this question is the same as your question "Is there anything better than Flatpages?"
django-cms allows you to arrange your flatpages in a hierarchical structure and lets you set a future publish date.
By custom fields I assume you mean fields defined by users? If so then you'll have to implement that yourself on top of django-cms.