<div><br><div class="gmail_quote"><div dir="auto">On Fri, 25 May 2018 at 9:42 PM, Paolo Bonzini <<a href="mailto:pbonzini@redhat.com">pbonzini@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 25/05/2018 17:57, Shubham Jain wrote:<br>
> <br>
> On Thu, 24 May 2018 at 9:39 PM, Paolo Bonzini <<a href="mailto:pbonzini@redhat.com" target="_blank">pbonzini@redhat.com</a><br>
> <mailto:<a href="mailto:pbonzini@redhat.com" target="_blank">pbonzini@redhat.com</a>>> wrote:<br>
> <br>
>     On 23/05/2018 21:16, Shubham Jain wrote:<br>
>     > moved and refactored the UpdateProjectHeadView.handle() into<br>
>     method of api.models.Project so that it can be re-used in rest<br>
>     conversion of update-project-head<br>
>     > ---<br>
>     >  api/models.py | 31 +++++++++++++++++++++++++++++++<br>
>     >  api/views.py  | 29 +++--------------------------<br>
>     >  2 files changed, 34 insertions(+), 26 deletions(-)<br>
>     ><br>
>     > diff --git a/api/models.py b/api/models.py<br>
>     > index d602cb7..1a51a6d 100644<br>
>     > --- a/api/models.py<br>
>     > +++ b/api/models.py<br>
>     > @@ -171,6 +171,37 @@ class Project(models.Model):<br>
>     >      def get_subprojects(self):<br>
>     >          return Project.objects.filter(parent_project=self)<br>
>     > <br>
>     > +    def get_project_head(self):<br>
>     > +        return self.get_property("git.head")<br>
>     > +<br>
>     > +    def set_project_head(self, new_head):<br>
>     > +        self.set_property("git.head", new_head)<br>
>     > +<br>
>     > +    project_head = property(get_project_head,set_project_head)<br>
> <br>
>     Fam, what do you think about making git.head a proper field in the<br>
>     model, rather than a property?<br>
> <br>
>     Shubham, if Fam agrees, would you like to try it?  It's outside the REST<br>
>     API project, but it is an interesting experience with Django to write<br>
>     the migration code etc.<br>
> <br>
> Yes. Can you elaborate? <br>
<br>
Let's finish this endpoint first. :)  In the meanwhile I'll have more<br>
infrastructure committed through the big Result refactoring that I<br>
posted a few days ago.<br>
<br>
> Also, if one of you can elaborate the use of pluginmethod field. I tried<br>
> going through code and experiment around it but it wasn’t a much help. <br>
<br>
PluginMethodField is like SerializerMethodField, but it calls a method<br>
on another object (the plugin).  There are some examples, such as in<br>
mods/tags.py if I remember correctly.  What are your doubts?</blockquote><div dir="auto">I am not  able to get the intuition behind it, like you would get with another things for eg a serialiser method field. How is it used? And how it helps in getting the desired results? </div><div dir="auto"><br></div><div dir="auto">Thanks</div><div dir="auto">Shubham </div></div></div>