Advertisement
Guest User

Untitled

a guest
May 29th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.27 KB | None | 0 0
  1. class BaseProfileFormView(UpdateView):
  2.     model = UserProfile
  3.     template_name = 'representation/profile/base.html'
  4.  
  5.     def get_object(self, queryset=None):
  6.         return self.model.objects.get_or_create(user=self.request.user)[0]
  7.  
  8.     def get_context_data(self, **kwargs):
  9.         context = super(BaseProfileFormView, self).get_context_data(**kwargs)
  10.         count = self.request.user.user_incoming_friend_requests.filter(denied=False, accepted=False).count()
  11.         context['request_friend_count'] = count if count > 0 else ''
  12.         return context
  13.  
  14.  
  15. class ProfileFormView(BaseProfileFormView):
  16.     form_class = AddOrEditProfile
  17.     success_url = reverse_lazy('representation:profile:base')
  18.  
  19.  
  20. class ContactFormView(BaseProfileFormView):
  21.     form_class = AddOrEditContact
  22.     template_name = 'representation/profile/contact.html'
  23.     success_url = reverse_lazy('representation:profile:contact')
  24.  
  25.  
  26. class UserPersonalFormView(BaseProfileFormView):
  27.     form_class = AddOrEditPersonalInfo
  28.     success_url = reverse_lazy('representation:profile:userinfo')
  29.  
  30.  
  31. class UserPhotoFormView(BaseProfileFormView):
  32.     form_class = AddOrEditUserAvatarPhoto
  33.     template_name = 'representation/profile/photo.html'
  34.     success_url = reverse_lazy('representation:profile:photo')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement