Merge branch 'develop' into feature/elasticsearch-establishment-tags
This commit is contained in:
commit
51d0ae0d60
|
|
@ -1,6 +1,5 @@
|
||||||
"""Serializers for account web"""
|
"""Serializers for account web"""
|
||||||
from django.contrib.auth import password_validation as password_validators
|
from django.contrib.auth import password_validation as password_validators
|
||||||
from django.utils.translation import gettext_lazy as _
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from account import models
|
from account import models
|
||||||
|
|
@ -25,7 +24,7 @@ class PasswordResetSerializer(serializers.Serializer):
|
||||||
|
|
||||||
if not user.is_authenticated:
|
if not user.is_authenticated:
|
||||||
if not username_or_email:
|
if not username_or_email:
|
||||||
raise serializers.ValidationError(_('username or email not in request body.'))
|
raise utils_exceptions.UserNotFoundError()
|
||||||
|
|
||||||
filters = {}
|
filters = {}
|
||||||
if username_validator(username_or_email):
|
if username_validator(username_or_email):
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ class OAuth2SignUpView(OAuth2ViewMixin, JWTGenericViewMixin):
|
||||||
source = serializer.validated_data.get('source')
|
source = serializer.validated_data.get('source')
|
||||||
request_data.update({
|
request_data.update({
|
||||||
'grant_type': settings.OAUTH2_SOCIAL_AUTH_GRANT_TYPE,
|
'grant_type': settings.OAUTH2_SOCIAL_AUTH_GRANT_TYPE,
|
||||||
'backend': settings.OAUTH2_SOCIAL_AUTH_BACKEND_NAME
|
'backend': settings.OAUTH2_SOCIAL_AUTH_BACKEND_NAME,
|
||||||
})
|
})
|
||||||
|
|
||||||
# Use the rest framework `.data` to fake the post body of the django request.
|
# Use the rest framework `.data` to fake the post body of the django request.
|
||||||
|
|
|
||||||
2
apps/location/serializers/__init__.py
Normal file
2
apps/location/serializers/__init__.py
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
from location.serializers.common import *
|
||||||
|
from location.serializers.back import *
|
||||||
22
apps/location/serializers/back.py
Normal file
22
apps/location/serializers/back.py
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
from django.contrib.gis.geos import Point
|
||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
from location import models
|
||||||
|
from location.serializers import common
|
||||||
|
|
||||||
|
|
||||||
|
class AddressCreateSerializer(common.AddressSerializer):
|
||||||
|
"""Address create serializer."""
|
||||||
|
|
||||||
|
|
||||||
|
class CountryBackSerializer(common.CountrySerializer):
|
||||||
|
"""Country back-office serializer."""
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = models.Country
|
||||||
|
fields = [
|
||||||
|
'id',
|
||||||
|
'code',
|
||||||
|
'svg_image',
|
||||||
|
'name',
|
||||||
|
]
|
||||||
|
|
@ -23,7 +23,12 @@ class CountrySerializer(serializers.ModelSerializer):
|
||||||
class RegionSerializer(serializers.ModelSerializer):
|
class RegionSerializer(serializers.ModelSerializer):
|
||||||
"""Region serializer"""
|
"""Region serializer"""
|
||||||
|
|
||||||
country = CountrySerializer()
|
country = CountrySerializer(read_only=True)
|
||||||
|
country_id = serializers.PrimaryKeyRelatedField(
|
||||||
|
source='country',
|
||||||
|
queryset=models.Country.objects.all(),
|
||||||
|
write_only=True
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Region
|
model = models.Region
|
||||||
|
|
@ -32,13 +37,24 @@ class RegionSerializer(serializers.ModelSerializer):
|
||||||
'name',
|
'name',
|
||||||
'code',
|
'code',
|
||||||
'parent_region',
|
'parent_region',
|
||||||
'country'
|
'country',
|
||||||
|
'country_id'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class CitySerializer(serializers.ModelSerializer):
|
class CitySerializer(serializers.ModelSerializer):
|
||||||
"""City serializer."""
|
"""City serializer."""
|
||||||
region = RegionSerializer()
|
region = RegionSerializer(read_only=True)
|
||||||
|
region_id = serializers.PrimaryKeyRelatedField(
|
||||||
|
source='region',
|
||||||
|
queryset=models.Region.objects.all(),
|
||||||
|
write_only=True
|
||||||
|
)
|
||||||
|
country_id = serializers.PrimaryKeyRelatedField(
|
||||||
|
source='country',
|
||||||
|
queryset=models.Country.objects.all(),
|
||||||
|
write_only=True
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.City
|
model = models.City
|
||||||
|
|
@ -47,6 +63,8 @@ class CitySerializer(serializers.ModelSerializer):
|
||||||
'name',
|
'name',
|
||||||
'code',
|
'code',
|
||||||
'region',
|
'region',
|
||||||
|
'region_id',
|
||||||
|
'country_id',
|
||||||
'postal_code',
|
'postal_code',
|
||||||
'is_island',
|
'is_island',
|
||||||
]
|
]
|
||||||
|
|
@ -54,13 +72,18 @@ class CitySerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
class AddressSerializer(serializers.ModelSerializer):
|
class AddressSerializer(serializers.ModelSerializer):
|
||||||
"""Address serializer."""
|
"""Address serializer."""
|
||||||
city = CitySerializer()
|
city_id = serializers.PrimaryKeyRelatedField(
|
||||||
|
source='city',
|
||||||
|
queryset=models.City.objects.all())
|
||||||
|
city = CitySerializer(read_only=True)
|
||||||
geo_lon = serializers.FloatField(allow_null=True)
|
geo_lon = serializers.FloatField(allow_null=True)
|
||||||
geo_lat = serializers.FloatField(allow_null=True)
|
geo_lat = serializers.FloatField(allow_null=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Address
|
model = models.Address
|
||||||
fields = [
|
fields = [
|
||||||
|
'id',
|
||||||
|
'city_id',
|
||||||
'city',
|
'city',
|
||||||
'street_name_1',
|
'street_name_1',
|
||||||
'street_name_2',
|
'street_name_2',
|
||||||
|
|
@ -74,9 +97,10 @@ class AddressSerializer(serializers.ModelSerializer):
|
||||||
# if geo_lat and geo_lon was sent
|
# if geo_lat and geo_lon was sent
|
||||||
geo_lat = attrs.pop('geo_lat') if 'geo_lat' in attrs else None
|
geo_lat = attrs.pop('geo_lat') if 'geo_lat' in attrs else None
|
||||||
geo_lon = attrs.pop('geo_lon') if 'geo_lon' in attrs else None
|
geo_lon = attrs.pop('geo_lon') if 'geo_lon' in attrs else None
|
||||||
|
|
||||||
if geo_lat and geo_lon:
|
if geo_lat and geo_lon:
|
||||||
# Point(longitude, latitude)
|
# Point(longitude, latitude)
|
||||||
attrs['location'] = Point(geo_lat, geo_lon)
|
attrs['coordinates'] = Point(geo_lat, geo_lon)
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
def to_representation(self, instance):
|
def to_representation(self, instance):
|
||||||
0
apps/location/urls/__init__.py
Normal file
0
apps/location/urls/__init__.py
Normal file
20
apps/location/urls/back.py
Normal file
20
apps/location/urls/back.py
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
"""Location app back-office urlconf."""
|
||||||
|
from django.urls import path
|
||||||
|
|
||||||
|
from location import views
|
||||||
|
|
||||||
|
app_name = 'location'
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('addresses/', views.AddressListCreateView.as_view(), name='address-list-create'),
|
||||||
|
path('addresses/<int:pk>/', views.AddressRUDView.as_view(), name='address-RUD'),
|
||||||
|
|
||||||
|
path('cities/', views.CityListCreateView.as_view(), name='city-list-create'),
|
||||||
|
path('cities/<int:pk>/', views.CityRUDView.as_view(), name='city-retrieve'),
|
||||||
|
|
||||||
|
path('countries/', views.CountryListCreateView.as_view(), name='country-list-create'),
|
||||||
|
path('countries/<int:pk>/', views.CountryRUDView.as_view(), name='country-retrieve'),
|
||||||
|
|
||||||
|
path('regions/', views.RegionListCreateView.as_view(), name='region-list-create'),
|
||||||
|
path('regions/<int:pk>/', views.RegionRUDView.as_view(), name='region-retrieve'),
|
||||||
|
]
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
"""Location app urlconf."""
|
"""Location app common urlconf."""
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from location import views
|
from location import views
|
||||||
7
apps/location/urls/mobile.py
Normal file
7
apps/location/urls/mobile.py
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
"""Location app mobile urlconf."""
|
||||||
|
from location.urls.common import urlpatterns as common_urlpatterns
|
||||||
|
|
||||||
|
|
||||||
|
urlpatterns = []
|
||||||
|
|
||||||
|
urlpatterns.extend(common_urlpatterns)
|
||||||
7
apps/location/urls/web.py
Normal file
7
apps/location/urls/web.py
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
"""Location app web urlconf."""
|
||||||
|
from location.urls.common import urlpatterns as common_urlpatterns
|
||||||
|
|
||||||
|
|
||||||
|
urlpatterns = []
|
||||||
|
|
||||||
|
urlpatterns.extend(common_urlpatterns)
|
||||||
2
apps/location/views/__init__.py
Normal file
2
apps/location/views/__init__.py
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
from location.views.common import *
|
||||||
|
from location.views.back import *
|
||||||
53
apps/location/views/back.py
Normal file
53
apps/location/views/back.py
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
"""Location app views."""
|
||||||
|
from rest_framework import generics
|
||||||
|
from rest_framework import permissions
|
||||||
|
|
||||||
|
from location import models, serializers
|
||||||
|
from location.views import common
|
||||||
|
|
||||||
|
|
||||||
|
# Address
|
||||||
|
class AddressListCreateView(common.AddressViewMixin, generics.ListCreateAPIView):
|
||||||
|
"""Create view for model Address."""
|
||||||
|
serializer_class = serializers.AddressSerializer
|
||||||
|
queryset = models.Address.objects.all()
|
||||||
|
|
||||||
|
|
||||||
|
class AddressRUDView(common.AddressViewMixin, generics.RetrieveUpdateDestroyAPIView):
|
||||||
|
"""RUD view for model Address."""
|
||||||
|
serializer_class = serializers.AddressSerializer
|
||||||
|
queryset = models.Address.objects.all()
|
||||||
|
|
||||||
|
|
||||||
|
# City
|
||||||
|
class CityListCreateView(common.CityViewMixin, generics.ListCreateAPIView):
|
||||||
|
"""Create view for model City."""
|
||||||
|
serializer_class = serializers.CitySerializer
|
||||||
|
|
||||||
|
|
||||||
|
class CityRUDView(common.CityViewMixin, generics.RetrieveUpdateDestroyAPIView):
|
||||||
|
"""RUD view for model City."""
|
||||||
|
serializer_class = serializers.CitySerializer
|
||||||
|
|
||||||
|
|
||||||
|
# Region
|
||||||
|
class RegionListCreateView(common.RegionViewMixin, generics.ListCreateAPIView):
|
||||||
|
"""Create view for model Region"""
|
||||||
|
serializer_class = serializers.RegionSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class RegionRUDView(common.RegionViewMixin, generics.RetrieveUpdateDestroyAPIView):
|
||||||
|
"""Retrieve view for model Region"""
|
||||||
|
serializer_class = serializers.RegionSerializer
|
||||||
|
|
||||||
|
|
||||||
|
# Country
|
||||||
|
class CountryListCreateView(common.CountryViewMixin, generics.ListCreateAPIView):
|
||||||
|
"""List/Create view for model Country."""
|
||||||
|
serializer_class = serializers.CountryBackSerializer
|
||||||
|
pagination_class = None
|
||||||
|
|
||||||
|
|
||||||
|
class CountryRUDView(common.CountryViewMixin, generics.RetrieveUpdateDestroyAPIView):
|
||||||
|
"""RUD view for model Country."""
|
||||||
|
serializer_class = serializers.CountryBackSerializer
|
||||||
|
|
@ -3,11 +3,10 @@ from rest_framework import generics
|
||||||
from rest_framework import permissions
|
from rest_framework import permissions
|
||||||
|
|
||||||
from location import models, serializers
|
from location import models, serializers
|
||||||
from utils.views import JWTGenericViewMixin
|
|
||||||
|
|
||||||
|
|
||||||
# Mixins
|
# Mixins
|
||||||
class CountryViewMixin(JWTGenericViewMixin, generics.GenericAPIView):
|
class CountryViewMixin(generics.GenericAPIView):
|
||||||
"""View Mixin for model Country"""
|
"""View Mixin for model Country"""
|
||||||
|
|
||||||
serializer_class = serializers.CountrySerializer
|
serializer_class = serializers.CountrySerializer
|
||||||
|
|
@ -115,13 +114,3 @@ class AddressListView(AddressViewMixin, generics.ListAPIView):
|
||||||
serializer_class = serializers.AddressSerializer
|
serializer_class = serializers.AddressSerializer
|
||||||
|
|
||||||
|
|
||||||
class AddressDestroyView(AddressViewMixin, generics.DestroyAPIView):
|
|
||||||
"""Destroy view for model Address"""
|
|
||||||
serializer_class = serializers.AddressSerializer
|
|
||||||
|
|
||||||
|
|
||||||
class AddressUpdateView(AddressViewMixin, generics.UpdateAPIView):
|
|
||||||
"""Update view for model Address"""
|
|
||||||
serializer_class = serializers.AddressSerializer
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -67,7 +67,7 @@ class JWTGenericViewMixin(generics.GenericAPIView):
|
||||||
# todo: remove config for develop
|
# todo: remove config for develop
|
||||||
from os import environ
|
from os import environ
|
||||||
configuration = environ.get('SETTINGS_CONFIGURATION', None)
|
configuration = environ.get('SETTINGS_CONFIGURATION', None)
|
||||||
if configuration == 'development':
|
if configuration == 'development' or configuration == 'stage':
|
||||||
response.set_cookie(key=cookie.key,
|
response.set_cookie(key=cookie.key,
|
||||||
value=cookie.value,
|
value=cookie.value,
|
||||||
secure=cookie.secure,
|
secure=cookie.secure,
|
||||||
|
|
|
||||||
|
|
@ -256,6 +256,10 @@ OAUTH2_PROVIDER_APPLICATION_MODEL = 'authorization.Application'
|
||||||
# Facebook configuration
|
# Facebook configuration
|
||||||
SOCIAL_AUTH_FACEBOOK_KEY = '386843648701452'
|
SOCIAL_AUTH_FACEBOOK_KEY = '386843648701452'
|
||||||
SOCIAL_AUTH_FACEBOOK_SECRET = 'a71cf0bf3980843a8f1ea74c6d805fd7'
|
SOCIAL_AUTH_FACEBOOK_SECRET = 'a71cf0bf3980843a8f1ea74c6d805fd7'
|
||||||
|
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email', ]
|
||||||
|
SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = {
|
||||||
|
'fields': 'id, name, email',
|
||||||
|
}
|
||||||
|
|
||||||
# SMS Settings
|
# SMS Settings
|
||||||
SMS_EXPIRATION = 5
|
SMS_EXPIRATION = 5
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
{% trans "Please go to the following page for confirmation new email address:" %}
|
{% trans "Please go to the following page for confirmation new email address:" %}
|
||||||
|
|
||||||
<a href="https://{{ country_code }}.{{ domain_uri }}/registered/{{ uidb64 }}/{{ token }}/">https://{{ country_code }}.{{ domain_uri }}/registered/{{ uidb64 }}/{{ token }}/</a>
|
https://{{ country_code }}.{{ domain_uri }}/registered/{{ uidb64 }}/{{ token }}/
|
||||||
|
|
||||||
{% trans "Thanks for using our site!" %}
|
{% trans "Thanks for using our site!" %}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
{% trans "Please go to the following page and choose a new password:" %}
|
{% trans "Please go to the following page and choose a new password:" %}
|
||||||
|
|
||||||
<a href="https://{{ country_code }}.{{ domain_uri }}/recovery/{{ uidb64 }}/{{ token }}/">https://{{ country_code }}.{{ domain_uri }}/recovery/{{ uidb64 }}/{{ token }}/</a>
|
https://{{ country_code }}.{{ domain_uri }}/recovery/{{ uidb64 }}/{{ token }}/
|
||||||
|
|
||||||
{% trans "Thanks for using our site!" %}
|
{% trans "Thanks for using our site!" %}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,7 @@
|
||||||
{% blocktrans %}You're receiving this email because you trying to register new account at {{ site_name }}.{% endblocktrans %}
|
{% blocktrans %}You're receiving this email because you trying to register new account at {{ site_name }}.{% endblocktrans %}
|
||||||
|
|
||||||
{% trans "Please confirm your email address to complete the registration:" %}
|
{% trans "Please confirm your email address to complete the registration:" %}
|
||||||
|
https://{{ country_code }}.{{ domain_uri }}/registered/{{ uidb64 }}/{{ token }}/
|
||||||
<a href="https://{{ country_code }}.{{ domain_uri }}/registered/{{ uidb64 }}/{{ token }}/">https://{{ country_code }}.{{ domain_uri }}/registered/{{ uidb64 }}/{{ token }}/</a>
|
|
||||||
|
|
||||||
{% trans "Thanks for using our site!" %}
|
{% trans "Thanks for using our site!" %}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,6 @@ app_name = 'back'
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('gallery/', include(('gallery.urls', 'gallery'),
|
path('gallery/', include(('gallery.urls', 'gallery'),
|
||||||
namespace='gallery')),
|
namespace='gallery')),
|
||||||
# path('account/', include('account.urls.web')),
|
|
||||||
# path('advertisement/', include('advertisement.urls.web')),
|
|
||||||
# path('collection/', include('collection.urls.web')),
|
|
||||||
path('establishments/', include('establishment.urls.back')),
|
path('establishments/', include('establishment.urls.back')),
|
||||||
# path('news/', include('news.urls.web')),
|
path('location/', include('location.urls.back')),
|
||||||
# path('partner/', include('partner.urls.web')),
|
|
||||||
]
|
]
|
||||||
|
|
@ -25,7 +25,7 @@ urlpatterns = [
|
||||||
path('news/', include('news.urls.web')),
|
path('news/', include('news.urls.web')),
|
||||||
path('notifications/', include('notification.urls.web')),
|
path('notifications/', include('notification.urls.web')),
|
||||||
path('partner/', include('partner.urls.web')),
|
path('partner/', include('partner.urls.web')),
|
||||||
path('location/', include('location.urls')),
|
path('location/', include('location.urls.web')),
|
||||||
path('main/', include('main.urls')),
|
path('main/', include('main.urls')),
|
||||||
path('translation/', include('translation.urls')),
|
path('translation/', include('translation.urls')),
|
||||||
path('comments/', include('comment.urls.web')),
|
path('comments/', include('comment.urls.web')),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user