Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BaseProfileFormView(UpdateView):
- model = UserProfile
- template_name = 'representation/profile/base.html'
- def get_object(self, queryset=None):
- return self.model.objects.get_or_create(user=self.request.user)[0]
- def get_context_data(self, **kwargs):
- context = super(BaseProfileFormView, self).get_context_data(**kwargs)
- count = self.request.user.user_incoming_friend_requests.filter(denied=False, accepted=False).count()
- context['request_friend_count'] = count if count > 0 else ''
- return context
- class ProfileFormView(BaseProfileFormView):
- form_class = AddOrEditProfile
- success_url = reverse_lazy('representation:profile:base')
- class ContactFormView(BaseProfileFormView):
- form_class = AddOrEditContact
- template_name = 'representation/profile/contact.html'
- success_url = reverse_lazy('representation:profile:contact')
- class UserPersonalFormView(BaseProfileFormView):
- form_class = AddOrEditPersonalInfo
- success_url = reverse_lazy('representation:profile:userinfo')
- class UserPhotoFormView(BaseProfileFormView):
- form_class = AddOrEditUserAvatarPhoto
- template_name = 'representation/profile/photo.html'
- success_url = reverse_lazy('representation:profile:photo')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement