[Patchew-devel] [PATCH v2] Refactoring of UpdateProjectHeadView.handle()

Paolo Bonzini pbonzini at redhat.com
Fri May 25 16:12:39 UTC 2018


On 25/05/2018 17:57, Shubham Jain wrote:
> 
> On Thu, 24 May 2018 at 9:39 PM, Paolo Bonzini <pbonzini at redhat.com
> <mailto:pbonzini at redhat.com>> wrote:
> 
>     On 23/05/2018 21:16, Shubham Jain wrote:
>     > moved and refactored the UpdateProjectHeadView.handle() into
>     method of api.models.Project so that it can be re-used in rest
>     conversion of update-project-head
>     > ---
>     >  api/models.py | 31 +++++++++++++++++++++++++++++++
>     >  api/views.py  | 29 +++--------------------------
>     >  2 files changed, 34 insertions(+), 26 deletions(-)
>     >
>     > diff --git a/api/models.py b/api/models.py
>     > index d602cb7..1a51a6d 100644
>     > --- a/api/models.py
>     > +++ b/api/models.py
>     > @@ -171,6 +171,37 @@ class Project(models.Model):
>     >      def get_subprojects(self):
>     >          return Project.objects.filter(parent_project=self)
>>     > +    def get_project_head(self):
>     > +        return self.get_property("git.head")
>     > +
>     > +    def set_project_head(self, new_head):
>     > +        self.set_property("git.head", new_head)
>     > +
>     > +    project_head = property(get_project_head,set_project_head)
> 
>     Fam, what do you think about making git.head a proper field in the
>     model, rather than a property?
> 
>     Shubham, if Fam agrees, would you like to try it?  It's outside the REST
>     API project, but it is an interesting experience with Django to write
>     the migration code etc.
> 
> Yes. Can you elaborate? 

Let's finish this endpoint first. :)  In the meanwhile I'll have more
infrastructure committed through the big Result refactoring that I
posted a few days ago.

> Also, if one of you can elaborate the use of pluginmethod field. I tried
> going through code and experiment around it but it wasn’t a much help. 

PluginMethodField is like SerializerMethodField, but it calls a method
on another object (the plugin).  There are some examples, such as in
mods/tags.py if I remember correctly.  What are your doubts?

Paolo




More information about the Patchew-devel mailing list