Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Dec 13, 2022
2 parents 80134fb + d91217b commit d3b27c8
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
API_VERSION = '2.2.52'
API_VERSION = '2.2.53'
API_BUILD = 'dev'
VERSION = API_VERSION + '-' + API_BUILD
__version__ = VERSION
8 changes: 5 additions & 3 deletions core/common/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
from django.core.mail import EmailMessage
from django.core.management import call_command
from django.template.loader import render_to_string
from django.utils import timezone
from django_elasticsearch_dsl.registries import registry
from pydash import get

from core.celery import app
from core.common.constants import CONFIRM_EMAIL_ADDRESS_MAIL_SUBJECT, PASSWORD_RESET_MAIL_SUBJECT
from core.common.utils import write_export_file, web_url, get_resource_class_from_resource_name, get_export_service, \
get_start_of_month, get_end_of_month, get_prev_month
get_end_of_month

logger = get_task_logger(__name__)

Expand Down Expand Up @@ -727,8 +728,9 @@ def monthly_usage_report(): # pragma: no cover
# runs on first of every month
# reports usage of prev month
from core.reports.models import MonthlyUsageReport
prev_month = get_prev_month()
report = MonthlyUsageReport(verbose=True, start=get_start_of_month(prev_month), end=get_end_of_month(prev_month))
now = timezone.now()
prev_month = now.replace(month=now.month - 1, day=1).date()
report = MonthlyUsageReport(verbose=True, start=prev_month, end=get_end_of_month(prev_month))
report.prepare()
html_body = render_to_string('monthly_usage_report_for_mail.html', report.get_result_for_email())
mail = EmailMessage(
Expand Down
13 changes: 13 additions & 0 deletions core/integration_tests/tests_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,19 @@ def test_get_200(self):
self.assertEqual(response.data['name'], self.user.name)
self.assertEqual(response.data['url'], self.user.uri)

random_user = UserProfileFactory()

response = self.client.get(
f'/users/{self.user.username}/',
HTTP_AUTHORIZATION='Token ' + random_user.get_token(),
format='json'
)

self.assertEqual(response.status_code, 200)
self.assertEqual(response.data['username'], self.user.username)
self.assertEqual(response.data['name'], self.user.name)
self.assertEqual(response.data['url'], self.user.uri)

def test_get_200_with_subscribed_orgs(self):
response = self.client.get(
f'/users/{self.user.username}/?includeSubscribedOrgs=false',
Expand Down
2 changes: 1 addition & 1 deletion core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@
},
'first-of-every-month': {
'task': 'core.common.tasks.monthly_usage_report',
'schedule': crontab(0, 0, day_of_month='1'),
'schedule': crontab(1, 0, day_of_month='1'),
},
}
CELERYBEAT_HEALTHCHECK_KEY = 'celery_beat_healthcheck'
Expand Down
2 changes: 1 addition & 1 deletion core/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def get_object(self, queryset=None):
if self.request.query_params.get('includeVerificationToken') and self.request.method == 'GET':
return instance

if not is_self and not is_admin:
if not is_self and not is_admin and self.request.method != 'GET':
raise PermissionDenied()

return instance
Expand Down
8 changes: 5 additions & 3 deletions startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ set -e
./wait_for_it.sh ${ES_HOST}:${ES_PORT} -t 0
./wait_for_it.sh ${REDIS_HOST}:${REDIS_PORT} -t 0

echo "Running DB migrations"
python manage.py migrate
if [[ "$SKIP_MIGRATE_DB" != "true" ]]; then
echo "Running DB migrations"
python manage.py migrate
fi

echo "Importing base entities"
python manage.py loaddata core/fixtures/*
Expand All @@ -29,4 +31,4 @@ else
python manage.py collectstatic
echo "Starting up the production server"
gunicorn core.wsgi:application --bind 0.0.0.0:${API_PORT:-8000} --capture-output --workers 4 --timeout 60 --keep-alive 60 #match ALB
fi
fi

0 comments on commit d3b27c8

Please sign in to comment.