Skip to content

Commit

Permalink
clean code to run locally (#354)
Browse files Browse the repository at this point in the history
* clean code to run locally

* debugging of docker and other issues

Co-authored-by: anamariaroman <anamariaromanvalencia@gmail.com>
  • Loading branch information
odenypeter and anamariaroman committed Oct 14, 2022
1 parent bece1c8 commit a93dd49
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 16 deletions.
2 changes: 1 addition & 1 deletion core/admin.py
Expand Up @@ -3,7 +3,7 @@
from django.utils.translation import ugettext_lazy as _

from core.models import CoreUser, CoreGroup, CoreSites, EmailTemplate, \
Industry, LogicModule, Organization, OrganizationType, Consortium
Industry, LogicModule, Organization, OrganizationType, Consortium, Partner


class LogicModuleAdmin(admin.ModelAdmin):
Expand Down
2 changes: 1 addition & 1 deletion core/migrations/0003_partner.py
Expand Up @@ -7,7 +7,7 @@
class Migration(migrations.Migration):

dependencies = [
('core', '0002_auto_20200303_1657'),
('core', '0001_initial'),
]

operations = [
Expand Down
17 changes: 17 additions & 0 deletions core/migrations/0007_auto_20220823_1406.py
@@ -0,0 +1,17 @@
# Generated by Django 2.2.28 on 2022-08-23 14:06

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('core', '0006_auto_20220620_0528'),
]

operations = [
migrations.AlterModelOptions(
name='partner',
options={'verbose_name_plural': 'Partners'},
),
]
7 changes: 6 additions & 1 deletion core/models.py
Expand Up @@ -318,7 +318,7 @@ class Consortium(models.Model):

class Meta:
ordering = ('name',)
verbose_name_plural = "Consortiums"
verbose_name_plural = 'Consortiums'

def save(self, *args, **kwargs):
if self.create_date is None:
Expand All @@ -336,3 +336,8 @@ class Partner(models.Model):
create_date = models.DateTimeField(null=True, blank=True)
edit_date = models.DateTimeField(null=True, blank=True)

class Meta:
verbose_name_plural = 'Partners'

def __str__(self):
return f'{self.name}' or f'{self.uuid}'
23 changes: 13 additions & 10 deletions core/views/coreuser.py
Expand Up @@ -14,7 +14,8 @@
from core.serializers import (CoreUserSerializer, CoreUserWritableSerializer, CoreUserInvitationSerializer,
CoreUserResetPasswordSerializer, CoreUserResetPasswordCheckSerializer,
CoreUserResetPasswordConfirmSerializer, CoreUserEmailAlertSerializer,
CoreUserProfileSerializer)
CoreUserProfileSerializer, CoreUserUpdateOrganizationSerializer,
CoreUserEmailNotificationSerializer)

from django.http import Http404
from rest_framework.views import APIView
Expand Down Expand Up @@ -280,6 +281,12 @@ def get_permissions(self):
queryset = CoreUser.objects.all()
permission_classes = (AllowAuthenticatedRead,)

color_codes = {
'error': '#cc3300',
'info': '#2196F3',
'success': '#339900'
}

@swagger_auto_schema(methods=['post'],
request_body=CoreUserEmailAlertSerializer,
responses=SUCCESS_RESPONSE)
Expand Down Expand Up @@ -308,7 +315,7 @@ def alert(self, request, *args, **kwargs):
'/app/shipment/edit/:'+str(message['shipment_id']))
else:
message['shipment_url'] = None
message['color'] = color_codes.get(message['severity'])
message['color'] = self.color_codes.get(message['severity'])
context = {
'message': message,
}
Expand Down Expand Up @@ -358,13 +365,6 @@ def update_profile(self, request, pk=None, *args, **kwargs):
serializer.save()
return Response(serializer.data)


color_codes = {
'error': '#cc3300',
'info': '#2196F3',
'success': '#339900'
}

@action(detail=False, methods=['patch'], name='Update Organization', url_path='update_org/(?P<pk>\d+)')
def update_info(self, request, pk=None, *args, **kwargs):
"""
Expand Down Expand Up @@ -403,7 +403,10 @@ def notification(self, request, *args, **kwargs):
send_email(email_address, subject, context, template_name, html_template_name)
except Exception as ex:
print('Exception: ', ex)

return Response(
{
'detail': 'The notification were sent successfully on email.',
}, status=status.HTTP_200_OK)
}, status=status.HTTP_200_OK
)

2 changes: 1 addition & 1 deletion core/views/organization.py
Expand Up @@ -58,7 +58,7 @@ def fetch_existing_orgs(self, request, pk=None, *args, **kwargs):
"""
Fetch Already existing Organizations in Buildly Core,
Any logged in user can access this
"""s
"""
# returns names of existing orgs in Buildly Core as a list
queryset = Organization.objects.all()
names = list()
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Expand Up @@ -66,7 +66,8 @@ services:
USE_PASSWORD_MINIMUM_LENGTH_VALIDATOR: "True"
PASSWORD_MINIMUM_LENGTH: "6"
USE_PASSWORD_COMMON_VALIDATOR: "True"
USE_PASSWORD_NUMERIC_VALIDATOR: "True" FRONTEND_URL: "http://localhost:3000/login/"
USE_PASSWORD_NUMERIC_VALIDATOR: "True"
FRONTEND_URL: "http://localhost:3000/login/"
EMAIL_HOST: "smtp.sendgrid.net"
EMAIL_HOST_USER: "apikey"
EMAIL_HOST_PASSWORD: "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"
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Expand Up @@ -11,7 +11,7 @@ futures==3.1.1
django-cors-headers==2.5.3
pyswagger==0.8.39
bravado-core==5.13.1
drf-yasg==1.10.2
drf-yasg==1.17.1
requests==2.25.0
aiohttp==3.7.4
django-auth-ldap==2.1.0
Expand Down

0 comments on commit a93dd49

Please sign in to comment.