# Path: comments/models.py
# class Site(models.Model):
#     domain = models.CharField(null=False, max_length=255)
#     admins = models.ManyToManyField(
#         CustomUser, blank=True, limit_choices_to={
#             'is_superuser': False,
#             'is_staff': True
#         })
#     anonymous_allowed = models.BooleanField(default=False)
#     rs_customer_id = models.CharField(max_length=255, null=True, blank=True)
# 
#     def __unicode__(self):
#         return self.domain


from django.http import HttpResponse, HttpResponseBadRequest
from django.shortcuts import render
from comments.models import Site
import json
    return decorator


def cross_domain_post_response(func):
    def decorator(request, *args, **kwargs):
        resp = func(request, *args, **kwargs)

        iframe_id = request.POST.get('iframeId', '')

        data = {
            "status_code": resp.status_code,
            "resp_data": resp.content,
            "request_path": request.path,
            "iframeId": iframe_id,
        }
        return render(
            request,
            'post_response.html',
            {'data': json.dumps(data)}
        )

    return decorator


def host_check(func):
    def decorator(request, *args, **kwargs):
        domain = request.POST.get('domain')

        if domain:
            try:

# Path: comments/models.py
# class Site(models.Model):
#     domain = models.CharField(null=False, max_length=255)
#     admins = models.ManyToManyField(
#         CustomUser, blank=True, limit_choices_to={
#             'is_superuser': False,
#             'is_staff': True
#         })
#     anonymous_allowed = models.BooleanField(default=False)
#     rs_customer_id = models.CharField(max_length=255, null=True, blank=True)
# 
#     def __unicode__(self):
#         return self.domain


# Path: comments/decorators.py
from django.http import HttpResponse, HttpResponseBadRequest
from django.shortcuts import render
from comments.models import Site
import json

    return decorator


def cross_domain_post_response(func):
    def decorator(request, *args, **kwargs):
        resp = func(request, *args, **kwargs)

        iframe_id = request.POST.get('iframeId', '')

        data = {
            "status_code": resp.status_code,
            "resp_data": resp.content,
            "request_path": request.path,
            "iframeId": iframe_id,
        }
        return render(
            request,
            'post_response.html',
            {'data': json.dumps(data)}
        )

    return decorator


def host_check(func):
    def decorator(request, *args, **kwargs):
        domain = request.POST.get('domain')

        if domain:
            try:

                Site.objects.get(domain=domain)