<commit_before># -*- coding: utf-8 -*-
from django.db import models
from django.db.models.signals import post_delete

from solo.models import SingletonModel

from accounts.models import ObjectProfileLink
from taggit.models import Tag

from makerscience_forum.models import MakerSciencePost
from makerscience_profile.models import MakerScienceProfile
from makerscience_catalog.models import  MakerScienceProjectTaggedItem, MakerScienceResourceTaggedItem

class MakerScienceStaticContent (SingletonModel):
    about = models.TextField(null=True, blank=True)
    about_team = models.TextField(null=True, blank=True)
    about_contact = models.TextField(null=True, blank=True)
    about_faq = models.TextField(null=True, blank=True)
    about_cgu = models.TextField(null=True, blank=True)

    project_thematic_selection = models.ManyToManyField(Tag, related_name='project_selection',
                                    limit_choices_to={'id__in' : MakerScienceProjectTaggedItem.objects.filter(tag_type='th').distinct('tag').values_list('tag', flat=True)},
                                    null=True, blank=True)
    resource_thematic_selection = models.ManyToManyField(Tag, related_name='resource_selection',
                                    limit_choices_to={'id__in' : MakerScienceResourceTaggedItem.objects.filter(tag_type='th').distinct('tag').values_list('tag', flat=True)},
                                    null=True, blank=True)


class PageViews(models.Model):
    client = models.CharField(max_length=255)
    resource_uri = models.CharField(max_length=255)


def clear_makerscience(sender, instance, **kwargs):
    if sender == MakerSciencePost:
        ObjectProfileLink.objects.filter(content_type__model='post',
                                      object_id=instance.parent.id).delete()
        instance.parent.delete()
    if sender == MakerScienceProfile:
        instance.parent.user.delete()

post_delete.connect(clear_makerscience, sender=MakerSciencePost)
post_delete.connect(clear_makerscience, sender=MakerScienceProfile)
<commit_msg>Delete place and adress on profile deletion<commit_after># -*- coding: utf-8 -*-
from django.db import models
from django.db.models.signals import post_delete

from solo.models import SingletonModel

from accounts.models import ObjectProfileLink
from taggit.models import Tag

from makerscience_forum.models import MakerSciencePost
from makerscience_profile.models import MakerScienceProfile
from makerscience_catalog.models import  MakerScienceProjectTaggedItem, MakerScienceResourceTaggedItem

class MakerScienceStaticContent (SingletonModel):
    about = models.TextField(null=True, blank=True)
    about_team = models.TextField(null=True, blank=True)
    about_contact = models.TextField(null=True, blank=True)
    about_faq = models.TextField(null=True, blank=True)
    about_cgu = models.TextField(null=True, blank=True)

    project_thematic_selection = models.ManyToManyField(Tag, related_name='project_selection',
                                    limit_choices_to={'id__in' : MakerScienceProjectTaggedItem.objects.filter(tag_type='th').distinct('tag').values_list('tag', flat=True)},
                                    null=True, blank=True)
    resource_thematic_selection = models.ManyToManyField(Tag, related_name='resource_selection',
                                    limit_choices_to={'id__in' : MakerScienceResourceTaggedItem.objects.filter(tag_type='th').distinct('tag').values_list('tag', flat=True)},
                                    null=True, blank=True)


class PageViews(models.Model):
    client = models.CharField(max_length=255)
    resource_uri = models.CharField(max_length=255)


def clear_makerscience(sender, instance, **kwargs):
    if sender == MakerSciencePost:
        ObjectProfileLink.objects.filter(content_type__model='post',
                                      object_id=instance.parent.id).delete()
        instance.parent.delete()
    if sender == MakerScienceProfile:
        instance.location.address.delete()
        instance.location.delete()
        instance.parent.user.delete()

post_delete.connect(clear_makerscience, sender=MakerSciencePost)
post_delete.connect(clear_makerscience, sender=MakerScienceProfile)

{'fraction_non_alphanumeric': 0.09513692162417375, 'fraction_numerical': 0.0033050047214353163, 'mean_word_length': 3.9267441860465118, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2334109', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1141, 'n_words': 196}