<commit_before>{% load i18n extra_tags %}
{% if favorited %}
    <a class="button unfollow-question" alt="">
        <span>{% trans 'Unfollow this discussion' %}</span>
    </a>
{% else %}
    <a class="button follow-question" alt="">
        <span>{%trans 'Follow this discussion' %}</span>
    </a>
{% endif %}
<div id="favorite-number" class="favorite-number{% if favorited %} my-favorite-number{% endif %}">
    {% if thread.favourite_count = 0 %}
    	{% trans 'No follower for the moment' %}
   	{% else %}
        {% blocktrans count count=thread.favourite_count %}{{count}} follower{% plural %}{{count}} followers{% endblocktrans %}
    {% endif %}
</div>
<p class="rss">
    <a href="{%url question_feed question.id %}" title='{% trans "subscribe to the rss feed" %}'>{% trans 'subscribe to rss feed' %}</a>
</p>

<script type="text/javascript"> 
    $(document).ready(function(){
        $(".unfollow-question, .follow-question").click(function(){
        	var button = $(this);
        	var mail_subscription_type = 0; //11 for subscribtion else 12
        	$.ajax({
				type: "POST",
				url: "{% url vote question.id %}",
				data: {'type' : 4,
					   'postId' : {{question.id}}
					   },
				success: function(data){
					if(data.success === 1){
						if(button.hasClass("unfollow-question")){
							button.find("span").html("{%trans 'Follow this discussion' %}");
							button.removeClass("unfollow-question").addClass("follow-question");
							mail_subscription_type = 11;
						}
						else if(button.hasClass("follow-question")){
							button.find("span").html("{%trans 'Unfollow this discussion' %}");
							button.removeClass("follow-question").addClass("unfollow-question");
							mail_subscription_type = 12;
						}
						if(mail_subscription_type == 11 || mail_subscription_type == 12){
							$.ajax({
								type: "POST",
								url: "{% url vote question.id %}",
								data: {'type' : mail_subscription_type,
									   'postId' : {{question.id}}
									   },
						 	});
					 	}
						if(data.count > 0){
							if(data.count == 1){
								$("#favorite-number").html("1 follower");
							}
							else {
								$("#favorite-number").html(data.count + " followers");
							}
						}
						else{
							$("#favorite-number").html("{% trans 'No follower for the moment' %}");
						}
					}
				},
				dataType: 'json'
				});
        	return false;
        });
    });
</script><commit_msg>Disable email subscription for anonymous user (closes #1539)<commit_after>{% load i18n extra_tags %}
{% if favorited %}
    <a class="button unfollow-question" alt="">
        <span>{% trans 'Unfollow this discussion' %}</span>
    </a>
{% else %}
    <a class="button follow-question" alt="">
        <span>{%trans 'Follow this discussion' %}</span>
    </a>
{% endif %}
<div id="favorite-number" class="favorite-number{% if favorited %} my-favorite-number{% endif %}">
    {% if thread.favourite_count = 0 %}
    	{% trans 'No follower for the moment' %}
   	{% else %}
        {% blocktrans count count=thread.favourite_count %}{{count}} follower{% plural %}{{count}} followers{% endblocktrans %}
    {% endif %}
</div>
<p class="rss">
    <a href="{%url question_feed question.id %}" title='{% trans "subscribe to the rss feed" %}'>{% trans 'subscribe to rss feed' %}</a>
</p>

<script type="text/javascript"> 
    $(document).ready(function(){
        $(".unfollow-question, .follow-question").click(function(){
        	{% if not request.user.is_authenticated %}
        	var msg = "{% trans 'Anonymous users cannot subscribe to questions'%} "
        	var pleaseLogin = "<a href='{% url userena_signin %}?next={{question.get_absolute_url}}'>{% trans 'please login' %}</a>";
        	showMessage($(this), msg+pleaseLogin);
        	{%else%}
        	var button = $(this);
        	var mail_subscription_type = 0; //11 for subscribtion else 12
        	$.ajax({
				type: "POST",
				url: "{% url vote question.id %}",
				data: {'type' : 4,
					   'postId' : {{question.id}}
					   },
				success: function(data){
					if(data.success === 1){
						if(button.hasClass("unfollow-question")){
							button.find("span").html("{%trans 'Follow this discussion' %}");
							button.removeClass("unfollow-question").addClass("follow-question");
							mail_subscription_type = 11;
						}
						else if(button.hasClass("follow-question")){
							button.find("span").html("{%trans 'Unfollow this discussion' %}");
							button.removeClass("follow-question").addClass("unfollow-question");
							mail_subscription_type = 12;
						}
						if(mail_subscription_type == 11 || mail_subscription_type == 12){
							$.ajax({
								type: "POST",
								url: "{% url vote question.id %}",
								data: {'type' : mail_subscription_type,
									   'postId' : {{question.id}}
									   },
						 	});
					 	}
						if(data.count > 0){
							if(data.count == 1){
								$("#favorite-number").html("1 follower");
							}
							else {
								$("#favorite-number").html(data.count + " followers");
							}
						}
						else{
							$("#favorite-number").html("{% trans 'No follower for the moment' %}");
						}
					}
				},
				dataType: 'json'
				});
			{%endif%}
        	return false;
        });
    });
</script>
{'fraction_non_alphanumeric': 0.18719118206005322, 'fraction_numerical': 0.008741923223109084, 'mean_word_length': 2.6422145328719724, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 39, 'https://': 0, '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': '4335202', 'n_tokens_mistral': 2169, 'n_tokens_neox': 1600, 'n_words': 362}