# Path: server/views.py
# class AjaxServerModerateView(PermissionRequiredMixin, SingleObjectMixin, View):
#     http_method_names = ('post', )
#     permission_required = 'server.moderate'
#     queryset = Server.objects.for_moderation()
# 
#     def post(self, request, *args, **kwargs):
#         server = self.get_object()
#         if request.POST['moderate'] == 'true':
#             server.moderated = True
#             server.moderation_message = ''
#             server.contact_verified = True
#         else:
#             server.moderated = False
#             server.moderation_message = request.POST['message']
#         server.save()
#         return HttpResponse()
# 
# Path: server/views.py
# class AjaxServerReconsiderView(MyServerMixin, SingleObjectMixin, RedirectView):
#     pattern_name = 'server:status'
# 
#     def get(self, request, *args, **kwargs):
#         server = self.get_object()
#         server.moderated = None
#         server.moderators_notified = False
#         server.moderation_message = ''
#         server.save()
# 
#         return super().get(request, *args, **kwargs)
# 
# Path: server/views.py
# class ModerateView(PermissionRequiredMixin, ListView):
#     permission_required = 'server.moderate'
#     queryset = Server.objects.order_by('domain').for_moderation()
#     template_name = 'server/server_list_moderate.html'
# 
# Path: server/views.py
# class MyServerListView(MyServerMixin, ListView):
#     queryset = Server.objects.order_by('domain')
#     template_name_suffix = '_list_user'
# 
# Path: server/views.py
# class ServerCreateView(LoginRequiredMixin, ContactVerificationMixin, CreateView):
#     form_class = CreateServerForm
#     model = Server
#     queryset = Server.objects.all()
#     template_name_suffix = '_create'
# 
#     def get_initial(self):
#         return {
#             'contact': self.request.user.jid,
#         }
# 
#     def form_valid(self, form):
#         form.instance.user = self.request.user
#         form.instance.contact_verified = self.is_contact_verified(form.instance)
# 
#         # Save instance to database
#         resp = super().form_valid(form)
# 
#         # Send contact confirmation if necessary and start server verification
#         self.send_contact_confirmation(form.instance)
#         verify_server.delay(form.instance.domain)
# 
#         return resp
# 
# Path: server/views.py
# class ServerDeleteView(MyServerMixin, DeleteView):
#     success_url = reverse_lazy('server:list')
# 
# Path: server/views.py
# class ServerStatusView(MyServerMixin, DetailView):
#     queryset = Server.objects.all()
#     template_name_suffix = '_status'
# 
# Path: server/views.py
# class ServerUpdateView(MyServerMixin, ContactVerificationMixin, UpdateView):
#     form_class = UpdateServerForm
#     template_name_suffix = '_update'
# 
#     def form_valid(self, form):
#         if form.contact_changed:
#             form.instance.contact_verified = self.is_contact_verified(form.instance)
# 
#         if form.moderation_changed:
#             form.instance.moderated = None  # not yet moderated, False == failed
#             form.instance.moderators_notified = False
#             form.instance.moderation_message = ''
# 
#         # Save instance to database
#         resp = super().form_valid(form)
# 
#         # Send contact confirmation if necessary
#         # NOTE: This form does not allow you to update any technical aspects, so there is no need to run
#         #       verify_servers() again
#         self.send_contact_confirmation(form.instance)
# 
#         return resp


from django.urls import path
from server.views import AjaxServerModerateView
from server.views import AjaxServerReconsiderView
from server.views import ModerateView
from server.views import MyServerListView
from server.views import ServerCreateView
from server.views import ServerDeleteView
from server.views import ServerStatusView
from server.views import ServerUpdateView
# This file is part of django-xmpp-server-list
# (https://github.com/mathiasertl/django-xmpp-server-list)
#
# django-xmpp-server-list is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# xmppllist is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with django-xmpp-server-list.  If not, see <http://www.gnu.org/licenses/>.



app_name = 'server'

urlpatterns = [
    path('', MyServerListView.as_view(), name='list'),
    path('add/', ServerCreateView.as_view(), name='add'),
    path('edit/<int:pk>/', ServerUpdateView.as_view(), name='edit'),
    path('reconsider/<int:pk>/', AjaxServerReconsiderView.as_view(), name='reconsider'),
    path('status/<int:pk>/', ServerStatusView.as_view(), name='status'),
    path('delete/<int:pk>/', ServerDeleteView.as_view(), name='delete'),

# Path: server/views.py
# class AjaxServerModerateView(PermissionRequiredMixin, SingleObjectMixin, View):
#     http_method_names = ('post', )
#     permission_required = 'server.moderate'
#     queryset = Server.objects.for_moderation()
# 
#     def post(self, request, *args, **kwargs):
#         server = self.get_object()
#         if request.POST['moderate'] == 'true':
#             server.moderated = True
#             server.moderation_message = ''
#             server.contact_verified = True
#         else:
#             server.moderated = False
#             server.moderation_message = request.POST['message']
#         server.save()
#         return HttpResponse()
# 
# Path: server/views.py
# class AjaxServerReconsiderView(MyServerMixin, SingleObjectMixin, RedirectView):
#     pattern_name = 'server:status'
# 
#     def get(self, request, *args, **kwargs):
#         server = self.get_object()
#         server.moderated = None
#         server.moderators_notified = False
#         server.moderation_message = ''
#         server.save()
# 
#         return super().get(request, *args, **kwargs)
# 
# Path: server/views.py
# class ModerateView(PermissionRequiredMixin, ListView):
#     permission_required = 'server.moderate'
#     queryset = Server.objects.order_by('domain').for_moderation()
#     template_name = 'server/server_list_moderate.html'
# 
# Path: server/views.py
# class MyServerListView(MyServerMixin, ListView):
#     queryset = Server.objects.order_by('domain')
#     template_name_suffix = '_list_user'
# 
# Path: server/views.py
# class ServerCreateView(LoginRequiredMixin, ContactVerificationMixin, CreateView):
#     form_class = CreateServerForm
#     model = Server
#     queryset = Server.objects.all()
#     template_name_suffix = '_create'
# 
#     def get_initial(self):
#         return {
#             'contact': self.request.user.jid,
#         }
# 
#     def form_valid(self, form):
#         form.instance.user = self.request.user
#         form.instance.contact_verified = self.is_contact_verified(form.instance)
# 
#         # Save instance to database
#         resp = super().form_valid(form)
# 
#         # Send contact confirmation if necessary and start server verification
#         self.send_contact_confirmation(form.instance)
#         verify_server.delay(form.instance.domain)
# 
#         return resp
# 
# Path: server/views.py
# class ServerDeleteView(MyServerMixin, DeleteView):
#     success_url = reverse_lazy('server:list')
# 
# Path: server/views.py
# class ServerStatusView(MyServerMixin, DetailView):
#     queryset = Server.objects.all()
#     template_name_suffix = '_status'
# 
# Path: server/views.py
# class ServerUpdateView(MyServerMixin, ContactVerificationMixin, UpdateView):
#     form_class = UpdateServerForm
#     template_name_suffix = '_update'
# 
#     def form_valid(self, form):
#         if form.contact_changed:
#             form.instance.contact_verified = self.is_contact_verified(form.instance)
# 
#         if form.moderation_changed:
#             form.instance.moderated = None  # not yet moderated, False == failed
#             form.instance.moderators_notified = False
#             form.instance.moderation_message = ''
# 
#         # Save instance to database
#         resp = super().form_valid(form)
# 
#         # Send contact confirmation if necessary
#         # NOTE: This form does not allow you to update any technical aspects, so there is no need to run
#         #       verify_servers() again
#         self.send_contact_confirmation(form.instance)
# 
#         return resp


# Path: server/urls.py
from django.urls import path
from server.views import AjaxServerModerateView
from server.views import AjaxServerReconsiderView
from server.views import ModerateView
from server.views import MyServerListView
from server.views import ServerCreateView
from server.views import ServerDeleteView
from server.views import ServerStatusView
from server.views import ServerUpdateView

# This file is part of django-xmpp-server-list
# (https://github.com/mathiasertl/django-xmpp-server-list)
#
# django-xmpp-server-list is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# xmppllist is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with django-xmpp-server-list.  If not, see <http://www.gnu.org/licenses/>.



app_name = 'server'

urlpatterns = [
    path('', MyServerListView.as_view(), name='list'),
    path('add/', ServerCreateView.as_view(), name='add'),
    path('edit/<int:pk>/', ServerUpdateView.as_view(), name='edit'),
    path('reconsider/<int:pk>/', AjaxServerReconsiderView.as_view(), name='reconsider'),
    path('status/<int:pk>/', ServerStatusView.as_view(), name='status'),
    path('delete/<int:pk>/', ServerDeleteView.as_view(), name='delete'),

    path('moderate/', ModerateView.as_view(), name='moderate'),