Skip to content

Commit

Permalink
Merge pull request #321 from FroggyTaipei/staging
Browse files Browse the repository at this point in the history
Release 1.6.3 to release
  • Loading branch information
travishen authored Feb 10, 2022
2 parents e3014d2 + 35b327e commit a56dcda
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.6
FROM python:3.8-slim

# python envs
ENV PYTHONFAULTHANDLER=1 \
Expand Down
8 changes: 4 additions & 4 deletions backend/apps/cases/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ def clean(self):

if new_state == 'published':
if case_state == 'draft':
raise ValidationError(f'新增處理事項前請先將案件由「尚未成案」設為「處理中」')
raise ValidationError('新增處理事項前請先將案件由「尚未成案」設為「處理中」')
if case_state == 'arranged' and self.instance.state == 'draft':
if any(field in self.changed_data for field in ['title', 'content']):
raise ValidationError('請先儲存變動後再設為發布')
if arrange_time is None:
raise ValidationError(f'請先設定案件處理時間')
raise ValidationError('請先設定案件處理時間')
else:
self.instance.arrange_time = arrange_time

if self.instance.pk is None and case_state == 'closed':
raise ValidationError(f'新增處理事項前請先將案件由「已結案」設為「處理中」')
raise ValidationError('新增處理事項前請先將案件由「已結案」設為「處理中」')

transition = None
for ts in self.instance.get_available_state_transitions():
Expand Down Expand Up @@ -116,7 +116,7 @@ class Meta:
def clean_mobile(self):
mobile = self.cleaned_data['mobile']
if mobile:
pattern = re.compile('^09\d{8}$')
pattern = re.compile(r'^09\d{8}$')
if not re.match(pattern, mobile):
raise ValidationError('手機格式不正確')
return mobile
Expand Down
2 changes: 1 addition & 1 deletion backend/apps/cases/insights.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def get_case_content_wordcloud_data():
data = data.strip()
stop.append(data)

pattern = re.compile('[\s+\.\!\/_,$%^*(+\"\']+|[+——!,。?“”、~@#¥%……&*()(\d+)]+')
pattern = re.compile(r'[\s+\.\!\/_,$%^*(+\"\']+|[+——!,。?“”、~@#¥%……&*()(\d+)]+')
content = pattern.sub("", content)

words_2 = [word for word in jieba.cut_for_search(content) if len(word) == 2 and word not in stop]
Expand Down
14 changes: 7 additions & 7 deletions backend/apps/mails/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.conf import settings
from django.core.serializers.json import DjangoJSONEncoder
from django.utils.translation import ugettext_lazy as _
from sendgrid.helpers.mail import Email, Mail
from sendgrid.helpers.mail import Email, Mail, From, To
from django.contrib.postgres.fields import HStoreField
from django.db.models import (
Model,
Expand Down Expand Up @@ -39,7 +39,7 @@ def save(self, *args, **kwargs):
super(SendGridMailTemplate, self).save(*args, **kwargs)

def retrieve_template(self):
sg = sendgrid.SendGridAPIClient(apikey=settings.SENDGRID_API_KEY)
sg = sendgrid.SendGridAPIClient(api_key=settings.SENDGRID_API_KEY)
return sg.client.templates._(self.tid).get()


Expand Down Expand Up @@ -89,14 +89,14 @@ def send(self):
@staticmethod
def send_template(from_email, to_email, data, template_id):
"""Call Sendgrid Transactional Template API"""
sg = sendgrid.SendGridAPIClient(apikey=settings.SENDGRID_API_KEY)
sg = sendgrid.SendGridAPIClient(api_key=settings.SENDGRID_API_KEY)
if from_email == settings.SERVER_EMAIL:
from_email = Email(from_email, name=settings.SERVER_EMAIL_NAME)
from_email = From(from_email, name=settings.SERVER_EMAIL_NAME)
else:
from_email = Email(from_email)
from_email = From(from_email)

mail = Mail(from_email=from_email, to_email=Email(to_email))
mail.personalizations[0].dynamic_template_data = json.loads(json.dumps(data, cls=DjangoJSONEncoder))
mail = Mail(from_email=from_email, to_emails=To(to_email))
mail.dynamic_template_data = json.loads(json.dumps(data, cls=DjangoJSONEncoder))
mail.template_id = template_id
try:
return sg.client.mail.send.post(request_body=mail.get())
Expand Down
2 changes: 1 addition & 1 deletion backend/config/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

# Cases API
api.register(r'cases', CaseViewSet)
api.register(r'cases/insights', CaseInsightViewSet, base_name='cases-insights')
api.register(r'cases/insights', CaseInsightViewSet, basename='cases-insights')
api.register(r'types', TypeViewSet)
api.register(r'regions', RegionViewSet)

Expand Down
54 changes: 27 additions & 27 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
Django==2.2.13
django-environ==0.4.5
flake8==3.5.0
gevent==1.3.6
gunicorn==19.9.0
Pillow==7.1.2
psycopg2-binary==2.7.5
requests==2.20.0
raven==6.9.0
PyYAML==5.1.1
djangorestframework==3.9.4
django-ckeditor==5.6.1
django-storages[google]==1.9.1
django-suit==0.2.26
Django==2.2.27
django-environ==0.8.1
flake8==4.0.1
gevent==21.12.0
gunicorn==20.1.0
Pillow==9.0.1
psycopg2-binary==2.8.6
requests==2.27.1
raven==6.10.0
PyYAML==6.0
djangorestframework==3.13.1
django-ckeditor==6.2.0
django-storages[google]==1.12.3
django-suit==0.2.28
django-suit-ckeditor==0.0.2
django-fsm==2.6.0
django-fsm==2.8.0
django-fsm-admin==1.2.4
sendgrid==5.6.0
django-sendgrid-v5==0.7.0
beautifulsoup4==4.7.1
drf-yasg==1.16.0
sendgrid==6.9.6
django-sendgrid-v5==1.2.0
beautifulsoup4==4.10.0
drf-yasg==1.20.0
djangorestframework-jwt==1.11.0
django-admin-lightweight-date-hierarchy==0.3.0
django-suit-daterange-filter==0.0.6
django-admin-lightweight-date-hierarchy==1.0.1
django-suit-daterange-filter==0.0.7
django-suit-dashboard==2.0.6
jieba==0.39
django-tagulous==0.13.2
slack_sdk==3.4.0
Unidecode==1.0.23
jieba==0.42.1
django-tagulous==1.3.3
slack_sdk==3.14.1
Unidecode==1.3.2
python-dateutil==2.8.1
firebase-admin==4.0.0
django-redis==4.11.0
firebase-admin==5.2.0
django-redis==5.2.0

0 comments on commit a56dcda

Please sign in to comment.