-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Get user feedback #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,10 @@ | |||||||||||||||||||||||||||||||
| from rest_framework.reverse import reverse | ||||||||||||||||||||||||||||||||
| from rest_framework.decorators import api_view | ||||||||||||||||||||||||||||||||
| from rest_framework.pagination import PageNumberPagination | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| from django.core.mail import send_mail | ||||||||||||||||||||||||||||||||
| from django.conf import settings | ||||||||||||||||||||||||||||||||
| from datetime import datetime | ||||||||||||||||||||||||||||||||
| from django.http import HttpResponse | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| class Pagination(PageNumberPagination): | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
@@ -14,6 +17,19 @@ def get_page_size(self, request): | |||||||||||||||||||||||||||||||
| return self.max_page_size | ||||||||||||||||||||||||||||||||
| return super().get_page_size(request) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Permit to send feedback emails from users | ||||||||||||||||||||||||||||||||
| @api_view(['POST']) | ||||||||||||||||||||||||||||||||
| def feedback(request, format=None): | ||||||||||||||||||||||||||||||||
| data = request.data | ||||||||||||||||||||||||||||||||
| if len(data['message']) < 2: | ||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
If there is no message in the POST data, |
||||||||||||||||||||||||||||||||
| return HttpResponse(status=500) | ||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should raise a 400 Bad Request error, you can maybe use ValidationError with a message like "Veuillez ajouter un message". Using a Serializer with a Model could help |
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| subject = "[WOOLLY][FeedBack] - " + data['reason'] + " - " + data['sender']['name'] | ||||||||||||||||||||||||||||||||
| message = 'Utilisateur : ' + data['sender']['name'] + '\n' + 'ID : ' + data['sender']['id'] + '\n' + 'Email : ' + data['sender']['email'] + '\n' + 'Date : ' + datetime.now().strftime("%d/%m/%Y, %H:%M:%S") + '\n' + 'Raison : ' + data['reason'] + '\n \n' + 'Message :' + '\n' + data['message'] | ||||||||||||||||||||||||||||||||
| message = message + '\n\nCe message a été généré automatiquement, merci de ne pas y répondre' | ||||||||||||||||||||||||||||||||
|
Comment on lines
+27
to
+29
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
You should also check that all the data attributes are present, maybe create a Model and a Serializer ? |
||||||||||||||||||||||||||||||||
| email_from = settings.EMAIL_HOST_USER | ||||||||||||||||||||||||||||||||
| send_mail(subject, message, email_from, settings.FEEDBACK_EMAILS ) | ||||||||||||||||||||||||||||||||
| return Response(data) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| @api_view(['GET']) | ||||||||||||||||||||||||||||||||
| def api_root(request, format=None): | ||||||||||||||||||||||||||||||||
|
|
@@ -45,6 +61,8 @@ def api_root(request, format=None): | |||||||||||||||||||||||||||||||
| 'orderlinefields': reverse('orderlinefields-list', **kwargs), | ||||||||||||||||||||||||||||||||
| 'orderlineitems': reverse('orderlineitems-list', **kwargs), | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # TODO PaymentMethods | ||||||||||||||||||||||||||||||||
| # 'paymentmethods': reverse('paymentmethods-list', **kwargs), | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ def make_path(rel: str) -> str: | |
| # Services Configuration | ||
| # -------------------------------------------------------------------------- | ||
|
|
||
|
|
||
| # PayUTC Payment services | ||
| PAYUTC = { | ||
| 'app_key': env.str("PAYUTC_APP_KEY"), | ||
|
|
@@ -65,13 +66,20 @@ def make_path(rel: str) -> str: | |
| } | ||
|
|
||
| # Email server | ||
| email = env.dj_email_url("EMAIL_URL") | ||
| EMAIL_HOST = email["EMAIL_HOST"] | ||
| EMAIL_PORT = email["EMAIL_PORT"] | ||
| EMAIL_HOST_USER = email["EMAIL_HOST_USER"] | ||
| EMAIL_HOST_PASSWORD = email["EMAIL_HOST_PASSWORD"] | ||
| EMAIL_USE_SSL = email["EMAIL_USE_SSL"] | ||
| EMAIL_USE_TLS = email["EMAIL_USE_TLS"] | ||
| # email = env.dj_email_url("EMAIL_URL") | ||
| # EMAIL_HOST = email["EMAIL_HOST"] | ||
| # EMAIL_PORT = email["EMAIL_PORT"] | ||
| # EMAIL_HOST_USER = email["EMAIL_HOST_USER"] | ||
| # EMAIL_HOST_PASSWORD = email["EMAIL_HOST_PASSWORD"] | ||
| # EMAIL_USE_SSL = email["EMAIL_USE_SSL"] | ||
| # EMAIL_USE_TLS = email["EMAIL_USE_TLS"] | ||
| EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' | ||
| EMAIL_HOST = 'smtp.gmail.com' | ||
| EMAIL_USE_TLS = True | ||
| EMAIL_PORT = 587 | ||
| EMAIL_HOST_USER = env.str("EMAIL_HOST_USER") | ||
| EMAIL_HOST_PASSWORD = env.str("EMAIL_HOST_PASSWORD") | ||
|
Comment on lines
+69
to
+81
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You'll need to revert that and use something like this in your personal .env: EMAIL_URL=stmp://user@domain:password@smtp.gmail.com:587?tls=True |
||
| FEEDBACK_EMAILS = env.list("FEEDBACK_EMAILS") | ||
|
|
||
| # -------------------------------------------------------------------------- | ||
| # Debug & Security | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,14 @@ | ||
| from django.conf.urls import url, include | ||
| from django.contrib import admin | ||
|
|
||
| from core.views import api_root | ||
| from core.views import api_root, feedback | ||
|
|
||
| urlpatterns = [ | ||
| url(r'^$', api_root, name='root'), # Api Root pour la documentation | ||
| url(r'^admin/', admin.site.urls, name='admin'), # Administration du site en backoffice | ||
| url(r'^', include('authentication.urls')), # Routes d'authentification | ||
| url(r'^', include('sales.urls')), # Routes pour les ventes | ||
| url(r'^', include('payment.urls')), # Routes pour les paiements | ||
| url(r'^feedback/?$', feedback, name='feedback'), | ||
|
|
||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Python Docstrings