Skip to content

Commit

Permalink
Merge pull request #84 from sebastienbarbier/develop
Browse files Browse the repository at this point in the history
Release v1.3.0
  • Loading branch information
sebastienbarbier authored May 9, 2023
2 parents 6536d03 + ae92ebe commit a8497d4
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 12 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ 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.3.0] - 2023-05-09
### 🛠 Improvements
- Apply **auto_sync settings for all accounts** instead of individual one (#81)
- **Log config** for easier deployment (#83)
### 🐛 Bug Fixes
- Settings **autosync** fails (#80)
- **Registration** returing 204 instead of 201 (#82)

## [1.2.0] - 2023-04-24
### ✨ Feature
- Publish **docker** image ([#69](https://github.com/sebastienbarbier/seven23_server/issues/69))
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.2'
version = '1.3'
# The full version, including alpha/beta/rc tags.
release = '1.2.0'
release = '1.3.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ DEBUG=1
Disable the creation of new user throught the application.

```shell
ALLOW_ACCOUNT_CREATION=0
ALLOW_ACCOUNT_CREATION=true # or False
```
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ s3transfer==0.6.0
sentry-sdk==1.19.1
simplejson==3.19.1
six==1.16.0
sqlparse==0.4.3
sqlparse==0.4.4
stripe==5.4.0
terminaltables==3.1.10
typing_extensions==4.5.0
Expand Down
17 changes: 17 additions & 0 deletions seven23/api/accounts/tests_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,23 @@ def test_account_post(self):
assert response.status_code == status.HTTP_200_OK
assert response.json()['name'] == 'Test creation'

def test_account_patch(self):
"""
We try to edit an account object
"""
self.client.force_authenticate(user=self.user)

response = self.client.get('/api/v1/accounts/%d' % self.account.id)
assert response.status_code == status.HTTP_200_OK

assert self.account.name == "Private Account"
self.account.name = "Public Account"
response = self.client.patch('/api/v1/accounts/%d' % self.account.id,
{'name': self.account.name,
})
assert response.status_code == status.HTTP_200_OK
assert response.json()['name'] == "Public Account"

def test_account_destroy(self):
"""
We try to edit an account object
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 @@ -47,4 +47,6 @@ def test_registration_new_user(self):
self.assertEqual(data['username'], 'test')
self.assertTrue('profile' in data)
self.assertTrue('avatar' in data['profile'])
self.assertTrue('social_networks' in data['profile'])
self.assertTrue('auto_sync' in data['profile'])
self.assertTrue('social_networks' in data['profile'])
self.assertFalse(data['profile']['auto_sync'])
22 changes: 22 additions & 0 deletions seven23/logs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from . import settings

def print_settings_report():
print('################################')
print('##### Seven23_server ####')
print('################################')

if settings.DEBUG:
print('✅ 🔎 🐛 Debug is enabled')

print(f'Version: {settings.VERSION[0]}.{settings.VERSION[1]}.{settings.VERSION[2]}')

if 'SECRET_KEY' in settings.errors:
print('⚠️ Secret key generated. Please set the environment variable SECRET_KEY to avoid this message.')

if 'ALLOW_ACCOUNT_CREATION' in settings.errors:
print('❌ 🙅‍♂️ Registration is disabled')
else:
print('✅ 🙋‍♂️ Registration is enabled')

if 'EMAIL_BACKEND' in settings.errors:
print('❌ ✉️ Emails are displayed in console')
1 change: 0 additions & 1 deletion seven23/models/accounts/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from seven23.models.accounts.models import Account, AccountGuests
from seven23.models.currency.models import Currency


from rest_framework_bulk import (
BulkListSerializer,
BulkSerializerMixin
Expand Down
18 changes: 18 additions & 0 deletions seven23/models/profile/migrations/0012_profile_auto_sync.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.1.8 on 2023-05-05 07:30

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('profile', '0011_profile_stripe_customer_id'),
]

operations = [
migrations.AddField(
model_name='profile',
name='auto_sync',
field=models.BooleanField(default=False, verbose_name='Auto sync in app'),
),
]
1 change: 1 addition & 0 deletions seven23/models/profile/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Profile(models.Model):
max_length=20,
choices=AVATAR_OPTIONS,
help_text=_(u'Select between different origins.'))
auto_sync = models.BooleanField(_(u'Auto sync in app'), default=False)
social_networks = models.TextField(_('social_networks blob'), blank=True, null=False)
last_api_call = models.DateField(_(u'Last API call'),
help_text=_(u'Last call on the API as a registered 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', 'social_networks']
fields = ['avatar', 'auto_sync', 'social_networks']


class DatetimeSerializer(serializers.HyperlinkedModelSerializer):
Expand Down
3 changes: 2 additions & 1 deletion seven23/models/profile/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ def test_profile_creation(self):
expected_date = timezone.now() + datetime.timedelta(days=settings.TRIAL_PERIOD)

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.valid_until < expected_date, True)
self.assertEqual(self.user.profile.auto_sync, False)
26 changes: 23 additions & 3 deletions seven23/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
import os
import dj_database_url

from django.core.management.utils import get_random_secret_key

from seven23.logs import print_settings_report

# Errors is an array of variable name as string
# to display report at the end of settings
errors = []

if os.environ.get('SENTRY_DSN'):
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
Expand All @@ -22,7 +30,7 @@
integrations=[DjangoIntegration()]
)

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

BASE_DIR = os.path.dirname(os.path.dirname(__file__))
Expand All @@ -31,13 +39,22 @@

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get('SECRET_KEY')
# If secret Key is empty we generate one
if not SECRET_KEY:
SECRET_KEY = get_random_secret_key()
errors.append("SECRET_KEY")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.environ.get('DEBUG', 'false').lower() == 'true'
MAINTENANCE = os.environ.get('MAINTENANCE', 'false').lower() == 'true'

# Allow public account creation
ALLOW_ACCOUNT_CREATION = os.environ.get('ALLOW_ACCOUNT_CREATION', 'false').lower() == 'true'
ALLOW_ACCOUNT_CREATION = \
os.environ.get('ALLOW_ACCOUNT_CREATION', 'false').lower() == 'true' or\
os.environ.get('ALLOW_ACCOUNT_CREATION', '0') == '1'
if not ALLOW_ACCOUNT_CREATION:
errors.append("ALLOW_ACCOUNT_CREATION")

OLD_PASSWORD_FIELD_ENABLED = True

APPEND_SLASH = True
Expand Down Expand Up @@ -233,8 +250,11 @@
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
EMAIL_USE_TLS = os.environ.get('EMAIL_USE_TLS')

if os.environ.get('EMAIL_BACKEND_CONSOLE', 'false').lower() == 'true' or not EMAIL_HOST:
if os.environ.get('EMAIL_BACKEND_CONSOLE', 'false').lower() == 'true' or\
os.environ.get('EMAIL_BACKEND_CONSOLE', '0') == '1' or\
not EMAIL_HOST:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
errors.append('EMAIL_BACKEND')

# Internationalization
# https://docs.djangoproject.com/en/1.6/topics/i18n/
Expand Down
5 changes: 4 additions & 1 deletion seven23/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
from drf_yasg import openapi

from . import views
from .logs import print_settings_report

admin.autodiscover()

# Print settings errors load for easier deployment
print_settings_report()

schema_view = get_schema_view(
openapi.Info(
title="Seven23 API",
Expand All @@ -26,7 +30,6 @@
permission_classes=(permissions.AllowAny,),
)


urlpatterns = [

# Examples:
Expand Down

0 comments on commit a8497d4

Please sign in to comment.