# Path: profile/models.py
# class Profile(models.Model):
#     user = models.OneToOneField(User, on_delete=models.CASCADE)
#     full_name = models.TextField()
#     notifications = models.ForeignKey('profile.Notifications', on_delete=models.CASCADE)
#     subscriptions = models.ManyToManyField('petitions.Petition', related_name='profile_subscriptions', blank=True)
#     petitions_created = models.ManyToManyField('petitions.Petition', related_name='profile_petitions_created', blank=True)
#     petitions_signed = models.ManyToManyField('petitions.Petition', related_name='profile_petitions_signed', blank=True)
#     display_name = models.CharField(max_length=3, blank=True)
#     # 0 - Does not have access, 1 - Has Access
#     has_access = models.PositiveSmallIntegerField(default=1)
# 
#     def __unicode__(self):
#         return self.user.username
# 
# Path: profile/models.py
# class GlobalAlert(models.Model):
#     active = models.BooleanField(default=True)
#     content = models.TextField()


import logging
from django.contrib.auth import login as auth_login
from django.contrib.auth import logout
from django.contrib.auth.decorators import login_required, user_passes_test
from django.contrib.auth.models import User
from django.conf import settings
from django.db.models import Q
from django.http import HttpResponse, HttpResponseForbidden, JsonResponse
from django.shortcuts import redirect, render
from django.views.decorators.http import require_POST
from .models import Profile
from profile.models import GlobalAlert
    """
    profile = Profile.objects.get(user=request.user)
    data_object = {
        'first_name': profile.user.first_name,
        'last_name': profile.user.last_name,
        'email': profile.user.email,
        'uid': profile.user.id,
        'notification_settings': profile.notifications,
        'petitions_created': profile.petitions_created.filter(~Q(status=2)),
        'main_logo': CONFIG['main_logo'],
        'analytics_id': settings.ANALYTICS,
        'name': CONFIG['name'],
        'generate_top_nav': CONFIG['generate_top_nav']
    }
    return render(request, 'profile.html', data_object)


@login_required
@user_passes_test(lambda u: u.is_superuser)
def admin(request):
    """
    Handles displaying the staff managing panel.
    User must be logged in and a superuser.
    """
    profile = Profile.objects.get(user=request.user)
    superusers = User.objects.filter(is_superuser=True)
    superusers_id = superusers.values("id")

    alert, created = GlobalAlert.objects.get_or_create(id=1, defaults={'active': 'False', 'content': 'Placeholder alert content.'})


# Path: profile/models.py
# class Profile(models.Model):
#     user = models.OneToOneField(User, on_delete=models.CASCADE)
#     full_name = models.TextField()
#     notifications = models.ForeignKey('profile.Notifications', on_delete=models.CASCADE)
#     subscriptions = models.ManyToManyField('petitions.Petition', related_name='profile_subscriptions', blank=True)
#     petitions_created = models.ManyToManyField('petitions.Petition', related_name='profile_petitions_created', blank=True)
#     petitions_signed = models.ManyToManyField('petitions.Petition', related_name='profile_petitions_signed', blank=True)
#     display_name = models.CharField(max_length=3, blank=True)
#     # 0 - Does not have access, 1 - Has Access
#     has_access = models.PositiveSmallIntegerField(default=1)
# 
#     def __unicode__(self):
#         return self.user.username
# 
# Path: profile/models.py
# class GlobalAlert(models.Model):
#     active = models.BooleanField(default=True)
#     content = models.TextField()


# Path: profile/views.py
import logging
from django.contrib.auth import login as auth_login
from django.contrib.auth import logout
from django.contrib.auth.decorators import login_required, user_passes_test
from django.contrib.auth.models import User
from django.conf import settings
from django.db.models import Q
from django.http import HttpResponse, HttpResponseForbidden, JsonResponse
from django.shortcuts import redirect, render
from django.views.decorators.http import require_POST
from .models import Profile
from profile.models import GlobalAlert

    """
    profile = Profile.objects.get(user=request.user)
    data_object = {
        'first_name': profile.user.first_name,
        'last_name': profile.user.last_name,
        'email': profile.user.email,
        'uid': profile.user.id,
        'notification_settings': profile.notifications,
        'petitions_created': profile.petitions_created.filter(~Q(status=2)),
        'main_logo': CONFIG['main_logo'],
        'analytics_id': settings.ANALYTICS,
        'name': CONFIG['name'],
        'generate_top_nav': CONFIG['generate_top_nav']
    }
    return render(request, 'profile.html', data_object)


@login_required
@user_passes_test(lambda u: u.is_superuser)
def admin(request):
    """
    Handles displaying the staff managing panel.
    User must be logged in and a superuser.
    """
    profile = Profile.objects.get(user=request.user)
    superusers = User.objects.filter(is_superuser=True)
    superusers_id = superusers.values("id")

    alert, created = GlobalAlert.objects.get_or_create(id=1, defaults={'active': 'False', 'content': 'Placeholder alert content.'})


    report_user_profiles = Profile.objects.filter(notifications__reported=True).distinct("id")