<commit_before># -*- coding: utf-8 -*-

# Connecting signal "comment_was_posted" to comment_notification()
def comment_notification(sender, comment, **kwargs):
    #import pdb; pdb.set_trace()
    ct_commented = comment.content_type
    if ct_commented.model == 'membershiprequest':
        msr = comment.content_object

        if msr.agent:
            msr_owner_name = msr.agent.name
        else:
            msr_owner_name = msr.name

        from django.conf import settings
        if "notification" in settings.INSTALLED_APPS:
            from notification import models as notification
            from django.contrib.auth.models import User
            users = User.objects.filter(is_staff=True)
            if users:
                from django.contrib.sites.models import Site
                site_name = Site.objects.get_current().name
                membership_url= "https://" + Site.objects.get_current().domain + "/accounting/membership-request/" + str(msr.id) + "/"
                notification.send(
                    users,
                    "comment_membership_request",
                    {"name": comment.name,
                    "comment": comment.comment,
                    "site_name": site_name,
                    "membership_url": membership_url,
                    }
)

    #TODO: other content types where comments are attached to.
    elif ct_commented.model == 'joinrequest':
        pass

from django_comments.models import Comment
from django_comments.signals import comment_was_posted
comment_was_posted.connect(comment_notification, sender=Comment)
<commit_msg>Adding the membership request creator to mailto list.<commit_after># -*- coding: utf-8 -*-

# Connecting signal "comment_was_posted" to comment_notification()
def comment_notification(sender, comment, **kwargs):
    #import pdb; pdb.set_trace()
    ct_commented = comment.content_type

    if ct_commented.model == 'membershiprequest':
        msr_creator_username = comment.content_object.requested_username

        from django.conf import settings
        if "notification" in settings.INSTALLED_APPS:
            from notification import models as notification
            from django.contrib.auth.models import User
            users = User.objects.filter(is_staff=True) | User.objects.filter(username=msr_creator_username)

            if users:
                from django.contrib.sites.models import Site
                site_name = Site.objects.get_current().name
                membership_url= "https://" + Site.objects.get_current().domain + "/accounting/membership-request/" + str(comment.content_object.id) + "/"
                notification.send(
                    users,
                    "comment_membership_request",
                    {"name": comment.name,
                    "comment": comment.comment,
                    "site_name": site_name,
                    "membership_url": membership_url,
                    }
)

    #TODO: other content types where comments are attached to.
    elif ct_commented.model == 'joinrequest':
        pass

from django_comments.models import Comment
from django_comments.signals import comment_was_posted
comment_was_posted.connect(comment_notification, sender=Comment)

{'fraction_non_alphanumeric': 0.087157376039421, 'fraction_numerical': 0.0006159531875577456, 'mean_word_length': 2.3176710929519917, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '62484', 'n_tokens_mistral': 865, 'n_tokens_neox': 820, 'n_words': 193}