Snipts count for user for intercom.
parent
8d9bdff1e2
commit
94db0dd3c9
|
@ -21,6 +21,7 @@
|
||||||
{% with 'true' as detail %}
|
{% with 'true' as detail %}
|
||||||
{% include "snipts/snipt-list.html" %}
|
{% include "snipts/snipt-list.html" %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
{% if not debug %}
|
||||||
<div id="disqus_thread"></div>
|
<div id="disqus_thread"></div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var disqus_shortname = 'snipt-net';
|
var disqus_shortname = 'snipt-net';
|
||||||
|
@ -37,5 +38,6 @@
|
||||||
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
{% endif %}
|
||||||
</section>
|
</section>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -3,7 +3,7 @@ from django import template
|
||||||
from templatetag_sugar.register import tag
|
from templatetag_sugar.register import tag
|
||||||
from templatetag_sugar.parser import Variable, Constant
|
from templatetag_sugar.parser import Variable, Constant
|
||||||
|
|
||||||
from snipts.models import Favorite
|
from snipts.models import Favorite, Snipt
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
|
@ -29,6 +29,19 @@ def snipt_is_favorited_by_user(context, asvar):
|
||||||
|
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
@tag(register, [])
|
||||||
|
def snipts_count_for_user(context):
|
||||||
|
|
||||||
|
user = context['request'].user
|
||||||
|
|
||||||
|
if user.is_authenticated():
|
||||||
|
snipts = Snipt.objects.filter(user=user).values('id').count()
|
||||||
|
else:
|
||||||
|
snipts = 0
|
||||||
|
|
||||||
|
return snipts
|
||||||
|
|
||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
def md5(string):
|
def md5(string):
|
||||||
return hashlib.md5(string.lower()).hexdigest()
|
return hashlib.md5(string.lower()).hexdigest()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% load compress %}
|
{% load compress snipt_tags %}
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en" class="{% block html-class %}{% endblock %}">
|
<html lang="en" class="{% block html-class %}{% endblock %}">
|
||||||
|
@ -263,6 +263,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if request.user.is_authenticated %}
|
{% if request.user.is_authenticated %}
|
||||||
|
{% if not debug %}
|
||||||
<script id="IntercomSettingsScriptTag">
|
<script id="IntercomSettingsScriptTag">
|
||||||
var intercomSettings = {
|
var intercomSettings = {
|
||||||
app_id: 'sajf131y',
|
app_id: 'sajf131y',
|
||||||
|
@ -270,7 +271,11 @@
|
||||||
created_at: {{ request.user.date_joined|date:"U" }},
|
created_at: {{ request.user.date_joined|date:"U" }},
|
||||||
widget: {
|
widget: {
|
||||||
activator: '#IntercomDefaultWidget',
|
activator: '#IntercomDefaultWidget',
|
||||||
label: 'Support'
|
label: 'Support Chat'
|
||||||
|
},
|
||||||
|
custom_data: {
|
||||||
|
'snipts count': {% snipts_count_for_user %},
|
||||||
|
'profile link': 'http://snipt.net/{{ request.user.username }}/'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -291,5 +296,6 @@
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue