# Path: server/apps/authentication/views.py
# class AccountDetailView(DetailView):
#     model = Account
#     template_name = 'authentication/detailVCard.html'
# 
#     def get_context_data(self, **kwargs):
#         context = super(AccountDetailView, self).get_context_data(**kwargs)
#         context['referer'] = self.request.META.get('HTTP_REFERER')
#         context['is_owner'] = (self.object == self.request.user)
#         return context
# 
#     @method_decorator(login_required)
#     def dispatch(self, request, *args, **kwargs):
#         return super(AccountDetailView, self).dispatch(request, *args, **kwargs)
# 
# class AccountRedirectView(View):
#     @method_decorator(login_required)
#     def get(self, request):
#         user = request.user
# 
#         return HttpResponseRedirect(reverse('account_detail', args=(user.username,)))
# 
# class AccountUpdateView(UpdateView):
#     model = Account
#     form_class = AccountUpdateForm
#     template_name = 'form.html'
# 
#     def form_valid(self, form):
#         self.object = form.save(commit=False)
#         self.object.time_zone = form.cleaned_data.get('time_zone')
#         self.object.save()
# 
#         # Update session as well
#         self.request.session['django_timezone'] = str(form.cleaned_data.get('time_zone'))
# 
#         return HttpResponseRedirect(self.get_success_url())
# 
#     def get_context_data(self, **kwargs):
#         context = super(AccountUpdateView, self).get_context_data(**kwargs)
#         context['referer'] = self.request.META.get('HTTP_REFERER')
# 
#         return context
# 
#     @method_decorator(login_required)
#     def dispatch(self, request, *args, **kwargs):
#         return super(AccountUpdateView, self).dispatch(request, *args, **kwargs)


from django.urls import include, path
from .views import AccountDetailView, AccountRedirectView, AccountUpdateView


urlpatterns = [

     path('', include('allauth.urls')),
     path('', AccountRedirectView.as_view(), name='account_redirect'),

# Path: server/apps/authentication/views.py
# class AccountDetailView(DetailView):
#     model = Account
#     template_name = 'authentication/detailVCard.html'
# 
#     def get_context_data(self, **kwargs):
#         context = super(AccountDetailView, self).get_context_data(**kwargs)
#         context['referer'] = self.request.META.get('HTTP_REFERER')
#         context['is_owner'] = (self.object == self.request.user)
#         return context
# 
#     @method_decorator(login_required)
#     def dispatch(self, request, *args, **kwargs):
#         return super(AccountDetailView, self).dispatch(request, *args, **kwargs)
# 
# class AccountRedirectView(View):
#     @method_decorator(login_required)
#     def get(self, request):
#         user = request.user
# 
#         return HttpResponseRedirect(reverse('account_detail', args=(user.username,)))
# 
# class AccountUpdateView(UpdateView):
#     model = Account
#     form_class = AccountUpdateForm
#     template_name = 'form.html'
# 
#     def form_valid(self, form):
#         self.object = form.save(commit=False)
#         self.object.time_zone = form.cleaned_data.get('time_zone')
#         self.object.save()
# 
#         # Update session as well
#         self.request.session['django_timezone'] = str(form.cleaned_data.get('time_zone'))
# 
#         return HttpResponseRedirect(self.get_success_url())
# 
#     def get_context_data(self, **kwargs):
#         context = super(AccountUpdateView, self).get_context_data(**kwargs)
#         context['referer'] = self.request.META.get('HTTP_REFERER')
# 
#         return context
# 
#     @method_decorator(login_required)
#     def dispatch(self, request, *args, **kwargs):
#         return super(AccountUpdateView, self).dispatch(request, *args, **kwargs)


# Path: server/apps/authentication/urls.py
from django.urls import include, path
from .views import AccountDetailView, AccountRedirectView, AccountUpdateView



urlpatterns = [

     path('', include('allauth.urls')),
     path('', AccountRedirectView.as_view(), name='account_redirect'),

     path('<slug:slug>/edit/', AccountUpdateView.as_view(), name='account_edit'),