Open ajatprabha opened 6 years ago
As a developer, I need to refactor the code in views.py, so that I can make use of correct Generic Class Based View and reduce the coupling in the code.
https://github.com/systers/portal/blob/3d870165ad0b93e55c084a2e463bede642ec6ff3/systers_portal/users/views.py#L12-L37
Since DetailView is a better choice than TemplateView, I suggest the following changes.
DetailView
TemplateView
class UserView(LoginRequiredMixin, DetailView): """User view""" template_name = "users/view_profile.html" model = SystersUser def get_object(self, queryset=None): return get_object_or_404(SystersUser, user__username=self.kwargs.get('username'))
JoinRequestManager will need a new method to be used in template as Django prohibits applying filters in template and should be implemented in Manager: https://github.com/systers/portal/blob/3d870165ad0b93e55c084a2e463bede642ec6ff3/systers_portal/membership/models.py#L8
JoinRequestManager
class JoinRequestManager(models.Manager): """Model manager for JoinRequest model""" # existing methods def unapproved(self): return self.filter(is_approved=False)
Other files which require change are in the gist. PS: There'll be no visual change in the frontend.
1-2 hour(s)
I think code refactoring is a lengthy task and can be reserved for GSoC 18
Sure @yatna, I'm planning to include this in my proposal. Thanks.
Description
As a developer, I need to refactor the code in views.py, so that I can make use of correct Generic Class Based View and reduce the coupling in the code.
Current Code Structure
https://github.com/systers/portal/blob/3d870165ad0b93e55c084a2e463bede642ec6ff3/systers_portal/users/views.py#L12-L37
Mocks
Since
DetailView
is a better choice thanTemplateView
, I suggest the following changes.JoinRequestManager
will need a new method to be used in template as Django prohibits applying filters in template and should be implemented in Manager: https://github.com/systers/portal/blob/3d870165ad0b93e55c084a2e463bede642ec6ff3/systers_portal/membership/models.py#L8Other files which require change are in the gist. PS: There'll be no visual change in the frontend.
Acceptance Criteria
Update [Required]
Definition of Done
Estimation
1-2 hour(s)