Commit 632898ee authored by Akshay Karthik's avatar Akshay Karthik

added qr, social click tracking via query param

parent 4a8076f8
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('go', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='url',
name='qrclicks',
field=models.IntegerField(default=0),
preserve_default=True,
),
migrations.AddField(
model_name='url',
name='socialclicks',
field=models.IntegerField(default=0),
preserve_default=True,
),
]
......@@ -21,9 +21,11 @@ class URL( models.Model ):
target = models.URLField( max_length = 1000 )
short = models.CharField( primary_key = True, max_length = 20 )
clicks = models.IntegerField( default = 0 )
expires = models.DateTimeField( blank = True, null = True )
qrclicks = models.IntegerField(default=0)
socialclicks = models.IntegerField(default=0)
expires = models.DateTimeField( blank = True, null = True )
def __unicode__(self):
return '<%s : %s>' % (self.owner.username, self.target)
......
......@@ -19,6 +19,11 @@
<strong>Clicks:</strong> {{url.clicks}}
<br />
<strong>QR Code Uses:</strong> {{url.qrclicks}}
<br />
<strong>Social Clicks:</strong> {{url.socialclicks}}
<br />
<strong>Expires:</strong> {{url.expires|default_if_none:"Never"}}
<br />
......@@ -33,21 +38,26 @@
<div class="col-md-4">
{% with domain|add:url.short as the_url %}
{% qr_from_text the_url 's' %}
<a class="share" href="http://twitter.com/share?url={{ the_url }}" target="_blank" title="Share via Twitter">
<i class="fa fa-twitter-square fa-3x"></i>
</a>
<a class="share" href="http://www.facebook.com/share.php?u={{ the_url }}" target="_blank" title="Share via Facebook">
<i class="fa fa-facebook-square fa-3x"></i>
</a>
<a class="share" href="https://plus.google.com/share?url={{ the_url }}" target="_blank" title="Share via Google+">
<i class="fa fa-google-plus-square fa-3x"></i>
</a>
<a class="share" href="http://www.linkedin.com/shareArticle?mini=true&amp;url={{ the_url }}&amp;ro=false&amp;summary=&amp;source=" target="_blank" title="Share via LinkedIn">
<i class="fa fa-linkedin-square fa-3x"></i>
</a>
{% with the_url|add:"?qr" as qr_url%}
{% qr_from_text qr_url 's' %}
{% endwith %}
{% with the_url|add:"?social" as social_url %}
<a class="share" href="http://twitter.com/share?url={{ social_url }}" target="_blank" title="Share via Twitter">
<i class="fa fa-twitter-square fa-3x"></i>
</a>
<a class="share" href="http://www.facebook.com/share.php?u={{ social_url }}" target="_blank" title="Share via Facebook">
<i class="fa fa-facebook-square fa-3x"></i>
</a>
<a class="share" href="https://plus.google.com/share?url={{ social_url }}" target="_blank" title="Share via Google+">
<i class="fa fa-google-plus-square fa-3x"></i>
</a>
<a class="share" href="http://www.linkedin.com/shareArticle?mini=true&amp;url={{ social_url }}&amp;ro=false&amp;summary=&amp;source=" target="_blank" title="Share via LinkedIn">
<i class="fa fa-linkedin-square fa-3x"></i>
</a>
{% endwith %}
{% endwith %}
</div>
......@@ -257,6 +257,13 @@ def redirection(request, short):
url = get_object_or_404( URL, short__iexact = short )
url.clicks = url.clicks + 1
if 'qr' in request.GET:
url.qrclicks += 1
if 'social' in request.GET:
url.socialclicks += 1
url.save()
"""
......
File mode changed from 100644 to 100755
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment