Skip to content

Commit

Permalink
Merge pull request #92 from sebastienbarbier/develop
Browse files Browse the repository at this point in the history
Release 1.4.0
  • Loading branch information
sebastienbarbier committed Jun 19, 2023
2 parents 1086e6c + dba2a30 commit eaca8ce
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 13 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
See for sample https://raw.githubusercontent.com/favoloso/conventional-changelog-emoji/master/CHANGELOG.md
-->

## [1.4.0] - 2023-06-19
### 🛠 Improvements
- Add boolean to **store if private key has been saved** and verified (#91)

## [1.3.1] - 2023-05-10
### 🔒 Security
- Bump django from 4.1.8 to 4.1.9 (#85)
- **Bump django** from *4.1.8* to *4.1.9* (#85)
### 🐛 Bug Fixes
- Fix crash settings if debug false (#86)
- **Fix crash** settings if debug false (#86)

## [1.3.0] - 2023-05-09
### 🛠 Improvements
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@
# built documents.
#
# The short X.Y version.
version = '1.3'
version = '1.4'
# The full version, including alpha/beta/rc tags.
release = '1.3.1'
release = '1.4.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
4 changes: 2 additions & 2 deletions docs/models_and_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ By default, your server instance deploy locally a swagger and redoc instance acc

You can also access the public instance on the seven23.io server:

- `Official swagger instance <https://seven23.io/swagger/>`_
- `Official redoc instance <https://seven23.io/redoc/>`_
- `Official swagger instance <https://api.seven23.io/swagger/>`_
- `Official redoc instance <https://api.seven23.io/redoc/>`_

Maintenance
-----------
Expand Down
4 changes: 3 additions & 1 deletion seven23/api/users/tests_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,7 @@ def test_registration_new_user(self):
self.assertTrue('profile' in data)
self.assertTrue('avatar' in data['profile'])
self.assertTrue('auto_sync' in data['profile'])
self.assertTrue('key_verified' in data['profile'])
self.assertTrue('social_networks' in data['profile'])
self.assertFalse(data['profile']['auto_sync'])
self.assertFalse(data['profile']['auto_sync'])
self.assertFalse(data['profile']['key_verified'])
2 changes: 1 addition & 1 deletion seven23/models/profile/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from seven23.models.profile.models import Profile

class ProfileAdmin(admin.ModelAdmin):
list_display = ('user', 'valid_until', 'last_api_call')
list_display = ('user', 'valid_until', 'key_verified','last_api_call')


admin.site.register(Profile, ProfileAdmin)
18 changes: 18 additions & 0 deletions seven23/models/profile/migrations/0013_profile_key_verified.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.1.8 on 2023-06-14 22:12

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('profile', '0012_profile_auto_sync'),
]

operations = [
migrations.AddField(
model_name='profile',
name='key_verified',
field=models.BooleanField(default=False, help_text='Private key has been verified and saved by user', verbose_name='Key verified'),
),
]
22 changes: 20 additions & 2 deletions seven23/models/profile/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
from django.utils import timezone
from django.contrib.auth.models import User
from django.utils.translation import gettext_lazy as _
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.core.mail import send_mail
from django.template.loader import render_to_string
# from seven23.models.stats.models import MonthlyActiveUser, DailyActiveUser
from django.db.models.signals import pre_delete
from django.db.models.signals import pre_delete, pre_save, post_save
from django.dispatch import receiver

from django.conf import settings
Expand Down Expand Up @@ -41,6 +40,9 @@ class Profile(models.Model):
valid_until = models.DateTimeField(_(u'Valid until'),
help_text=_(u'On SASS, this is the validation date'),
default=timezone.now)
key_verified = models.BooleanField(_(u'Key verified'),
help_text=_(u'Private key has been verified and saved by user'),
default=False)
stripe_customer_id = models.CharField(_(u'Stripe costumer id'),
max_length=128,
null=True,
Expand Down Expand Up @@ -74,6 +76,22 @@ def save_user_profile(sender, instance, **kwargs):
else:
Profile.objects.create(user=instance)

@receiver(pre_save, sender=User)
def user_updated_password(sender, **kwargs):
"""
When user update his password, we need to reset the key_verified flag
"""
user = kwargs.get('instance', None)
if user and hasattr(user, 'profile'):
new_password = user.password
try:
old_password = User.objects.get(pk=user.pk).password
except User.DoesNotExist:
old_password = None
if new_password != old_password:
user.profile.key_verified = False
user.profile.save()

def __str__(self):
return u'%s' % (self.user)

Expand Down
2 changes: 1 addition & 1 deletion seven23/models/profile/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class ProfileSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Profile
fields = ['avatar', 'auto_sync', 'social_networks']
fields = ['avatar', 'auto_sync', 'key_verified', 'social_networks']


class DatetimeSerializer(serializers.HyperlinkedModelSerializer):
Expand Down
12 changes: 11 additions & 1 deletion seven23/models/profile/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,14 @@ def test_profile_creation(self):

self.assertEqual(self.user.profile.valid_until > timezone.now(), True)
self.assertEqual(self.user.profile.valid_until < expected_date, True)
self.assertEqual(self.user.profile.auto_sync, False)
self.assertEqual(self.user.profile.auto_sync, False)
self.assertEqual(self.user.profile.key_verified, False)

self.user.profile.key_verified = True
self.user.profile.save()
self.assertEqual(self.user.profile.key_verified, True)

# Verify if changing password set key_verified flag to False using signals
self.user.password = "AnOtherLongPassword"
self.user.save()
self.assertEqual(self.user.profile.key_verified, False)
2 changes: 1 addition & 1 deletion seven23/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
integrations=[DjangoIntegration()]
)

VERSION = [1, 3, 1]
VERSION = [1, 4, 0]
API_VERSION = [1, 0, 0]

BASE_DIR = os.path.dirname(os.path.dirname(__file__))
Expand Down

0 comments on commit eaca8ce

Please sign in to comment.