mirror of
https://git.linux-kernel.at/oliver/ivatar.git
synced 2025-11-17 05:28:03 +00:00
Track access counts and show them on mouseover
This commit is contained in:
23
ivatar/ivataraccount/migrations/0011_auto_20181107_1550.py
Normal file
23
ivatar/ivataraccount/migrations/0011_auto_20181107_1550.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 2.1.3 on 2018-11-07 15:50
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('ivataraccount', '0010_auto_20180705_1201'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='photo',
|
||||||
|
name='access_count',
|
||||||
|
field=models.BigIntegerField(default=0, editable=False),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='userpreference',
|
||||||
|
name='theme',
|
||||||
|
field=models.CharField(choices=[('default', 'Default theme'), ('clime', 'climes theme'), ('falko', 'falkos theme')], default='default', max_length=10),
|
||||||
|
),
|
||||||
|
]
|
||||||
23
ivatar/ivataraccount/migrations/0012_auto_20181107_1732.py
Normal file
23
ivatar/ivataraccount/migrations/0012_auto_20181107_1732.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 2.1.3 on 2018-11-07 17:32
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('ivataraccount', '0011_auto_20181107_1550'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='confirmedemail',
|
||||||
|
name='access_count',
|
||||||
|
field=models.BigIntegerField(default=0, editable=False),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='confirmedopenid',
|
||||||
|
name='access_count',
|
||||||
|
field=models.BigIntegerField(default=0, editable=False),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -114,6 +114,7 @@ class Photo(BaseAccountModel):
|
|||||||
ip_address = models.GenericIPAddressField(unpack_ipv4=True)
|
ip_address = models.GenericIPAddressField(unpack_ipv4=True)
|
||||||
data = models.BinaryField()
|
data = models.BinaryField()
|
||||||
format = models.CharField(max_length=3)
|
format = models.CharField(max_length=3)
|
||||||
|
access_count = models.BigIntegerField(default=0, editable=False)
|
||||||
|
|
||||||
class Meta: # pylint: disable=too-few-public-methods
|
class Meta: # pylint: disable=too-few-public-methods
|
||||||
'''
|
'''
|
||||||
@@ -304,6 +305,7 @@ class ConfirmedEmail(BaseAccountModel):
|
|||||||
digest = models.CharField(max_length=32)
|
digest = models.CharField(max_length=32)
|
||||||
digest_sha256 = models.CharField(max_length=64)
|
digest_sha256 = models.CharField(max_length=64)
|
||||||
objects = ConfirmedEmailManager()
|
objects = ConfirmedEmailManager()
|
||||||
|
access_count = models.BigIntegerField(default=0, editable=False)
|
||||||
|
|
||||||
class Meta: # pylint: disable=too-few-public-methods
|
class Meta: # pylint: disable=too-few-public-methods
|
||||||
'''
|
'''
|
||||||
@@ -419,6 +421,7 @@ class ConfirmedOpenId(BaseAccountModel):
|
|||||||
on_delete=models.deletion.SET_NULL,
|
on_delete=models.deletion.SET_NULL,
|
||||||
)
|
)
|
||||||
digest = models.CharField(max_length=64)
|
digest = models.CharField(max_length=64)
|
||||||
|
access_count = models.BigIntegerField(default=0, editable=False)
|
||||||
|
|
||||||
class Meta: # pylint: disable=too-few-public-methods
|
class Meta: # pylint: disable=too-few-public-methods
|
||||||
'''
|
'''
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ outline: inherit;
|
|||||||
</div>
|
</div>
|
||||||
<div class="panel-body" style="height:130px">
|
<div class="panel-body" style="height:130px">
|
||||||
<center>
|
<center>
|
||||||
<img style="max-height:100px;max-width:100px" src="{% if email.photo %}{% url 'raw_image' email.photo.id %}{% else %}{% static '/img/nobody/80.png' %}{% endif %}">
|
<img title="{% trans 'Access count' %}: {{ email.access_count }}" style="max-height:100px;max-width:100px" src="{% if email.photo %}{% url 'raw_image' email.photo.id %}{% else %}{% static '/img/nobody/80.png' %}{% endif %}">
|
||||||
</center>
|
</center>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -71,7 +71,7 @@ outline: inherit;
|
|||||||
</div>
|
</div>
|
||||||
<div class="panel-body" style="height:130px">
|
<div class="panel-body" style="height:130px">
|
||||||
<center>
|
<center>
|
||||||
<img style="max-height:100px;max-width:100px" src="{% if openid.photo %}{% url 'raw_image' openid.photo.id %}{% else %}{% static '/img/nobody/80.png' %}{% endif %}">
|
<img title="{% trans 'Access count' %}: {{ openid.access_count }}" style="max-height:100px;max-width:100px" src="{% if openid.photo %}{% url 'raw_image' openid.photo.id %}{% else %}{% static '/img/nobody/80.png' %}{% endif %}">
|
||||||
</center>
|
</center>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -119,7 +119,7 @@ outline: inherit;
|
|||||||
</div>
|
</div>
|
||||||
<div class="panel-body" style="height:130px">
|
<div class="panel-body" style="height:130px">
|
||||||
<center>
|
<center>
|
||||||
<img style="max-height:100px;max-width:100px" src="{% url 'raw_image' photo.id %}">
|
<img title="{% trans 'Access count' %}: {{ photo.access_count }}" style="max-height:100px;max-width:100px" src="{% url 'raw_image' photo.id %}">
|
||||||
</center>
|
</center>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -136,7 +136,10 @@ class AvatarImageView(TemplateView):
|
|||||||
data = BytesIO()
|
data = BytesIO()
|
||||||
photodata.save(data, pil_format(imgformat), quality=JPEG_QUALITY)
|
photodata.save(data, pil_format(imgformat), quality=JPEG_QUALITY)
|
||||||
data.seek(0)
|
data.seek(0)
|
||||||
|
obj.photo.access_count += 1
|
||||||
|
obj.photo.save()
|
||||||
|
obj.access_count += 1
|
||||||
|
obj.save()
|
||||||
return HttpResponse(
|
return HttpResponse(
|
||||||
data,
|
data,
|
||||||
content_type='image/%s' % imgformat)
|
content_type='image/%s' % imgformat)
|
||||||
|
|||||||
Reference in New Issue
Block a user