Skip to content

Commit

Permalink
Merge branch 'master' into ato-documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rogeruiz authored Mar 29, 2018
2 parents ae6bbff + 50ac38c commit aeea1ed
Show file tree
Hide file tree
Showing 25 changed files with 480 additions and 107 deletions.
80 changes: 0 additions & 80 deletions about.yml

This file was deleted.

27 changes: 27 additions & 0 deletions bin/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,32 @@ else
fi
fi


if [[ -f VERSION ]]
then
VERSION=$(cat VERSION)
else
VERSION="Manual Deployment"
fi

NEW_RELIC_API_KEY=$(
echo "${VCAP_SERVICES}" | \
jq '.[] | map(select(.name == "tock-credentials")) | .[].credentials.NEW_RELIC_API_KEY' -r
)

# Append New Relic API key to New Relic INI file for `newrelic-admin` tool
cat <<EOF >> "${NEW_RELIC_CONFIG_FILE}"
# Adding license key from script $(basename "${0}")
api_key=${NEW_RELIC_API_KEY}
EOF

DEPLOYMENT_DESCRIPTION="Recording deployment of ${VERSION}."

echo "${DEPLOYMENT_DESCRIPTION}"

# Record deployment using the New Relic Python Admin CLI
newrelic-admin record-deploy "${NEW_RELIC_CONFIG_FILE}" "${DEPLOYMENT_DESCRIPTION}"

python manage.py collectstatic --settings=tock.settings.production --noinput
gunicorn -t 120 -k gevent -w 2 tock.wsgi:application
4 changes: 4 additions & 0 deletions tock/api/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from django.apps import AppConfig

class ApiAppConfig(AppConfig):
name = "api"
1 change: 1 addition & 0 deletions tock/api/signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Create your signal connections here.
8 changes: 8 additions & 0 deletions tock/employees/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.apps import AppConfig
from .signals import setup_signals

class EmployeesAppConfig(AppConfig):
name = "employees"

def ready(self):
setup_signals()
1 change: 1 addition & 0 deletions tock/employees/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from organizations.models import Organization
from projects.models import ProfitLossAccount


class EmployeeGrade(models.Model):
GRADE_CHOICES = (
(1, '1'),
Expand Down
33 changes: 33 additions & 0 deletions tock/employees/signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import logging

from django.db.models.signals import pre_save

logger = logging.getLogger('tock-employees')


def employee_grade_creation(sender, instance=None, **kwargs):
if instance is not None and instance.pk is None:
logger.info(
f'Creating EmployeeGrade for {instance.employee.username}.'
)

def user_data_creation(sender, instance=None, **kwargs):
if instance is not None and instance.pk is None:
logger.info(
f'Creating UserData for {instance.user.username}.'
)


def setup_signals():
from .models import EmployeeGrade, UserData

pre_save.connect(
employee_grade_creation,
sender=EmployeeGrade,
dispatch_uid="employees_employee_grade_creation"
)
pre_save.connect(
user_data_creation,
sender=UserData,
dispatch_uid="employees_user_data_creation"
)
1 change: 0 additions & 1 deletion tock/employees/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from .forms import UserForm
from .models import UserData


def parse_date(date):
if date == 'NA':
return None
Expand Down
8 changes: 8 additions & 0 deletions tock/hours/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.apps import AppConfig
from .signals import setup_signals

class HoursAppConfig(AppConfig):
name = "hours"

def ready(self):
setup_signals()
3 changes: 3 additions & 0 deletions tock/hours/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ def hours(self):
def notes_list(self):
return self.notes.split('\n')

def __str__(self):
return f'{self.timecard} {self.project}'

def save(self, *args, **kwargs):
"""Custom save() method to append employee grade info and the submitted
status of the related timecard."""
Expand Down
97 changes: 97 additions & 0 deletions tock/hours/signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import logging

from django.db.models.signals import pre_save

logger = logging.getLogger('tock-hours')


def holiday_prefills_creation(sender, instance=None, **kwargs):
if instance is not None and instance.pk is None:
logger.info(
f'Creating HolidayPrefills for {instance}.'
)


def reporting_period_creation(sender, instance=None, **kwargs):
if instance is not None and instance.pk is None:
logger.info(
f'Creating ReportingPeriod for {instance}.'
)


def targets_creation(sender, instance=None, **kwargs):
if instance is not None and instance.pk is None:
logger.info(
f'Creating Targets for {instance}.'
)


def timecard_creation(sender, instance=None, **kwargs):
if instance is not None and instance.pk is None:
logger.info(
f'Creating Timecard for {instance}.'
)


def timecard_note_creation(sender, instance=None, **kwargs):
if instance is not None and instance.pk is None:
logger.info(
f'Creating TimecardNote for {instance}.'
)


def timecard_object_creation(sender, instance=None, **kwargs):
if instance is not None and instance.pk is None:
logger.info(
f'Creating TimecardObject for {instance}.'
)


def timecard_prefill_data_creation(sender, instance=None, **kwargs):
if instance is not None and instance.pk is None:
logger.info(
f'Creating TimecardPrefillData for {instance}.'
)


def setup_signals():
from .models import (
HolidayPrefills, ReportingPeriod, Targets, Timecard, TimecardNote,
TimecardObject, TimecardPrefillData
)

pre_save.connect(
holiday_prefills_creation,
sender=HolidayPrefills,
dispatch_uid="hours_holiday_prefills_creation"
)
pre_save.connect(
reporting_period_creation,
sender=ReportingPeriod,
dispatch_uid="hours_reporting_period_creation"
)
pre_save.connect(
targets_creation,
sender=Targets,
dispatch_uid="hours_targets_creation"
)
pre_save.connect(
timecard_creation,
sender=Timecard,
dispatch_uid="hours_timecard_creation"
)
pre_save.connect(
timecard_note_creation,
sender=TimecardNote,
dispatch_uid="hours_timecard_note_creation"
)
pre_save.connect(
timecard_object_creation,
sender=TimecardObject,
dispatch_uid="hours_timecard_object_creation"
)
pre_save.connect(
timecard_prefill_data_creation,
sender=TimecardPrefillData,
dispatch_uid="hours_timecard_prefill_data_creation"
)
8 changes: 8 additions & 0 deletions tock/organizations/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.apps import AppConfig
from .signals import setup_signals

class OrganizationsAppConfig(AppConfig):
name = "organizations"

def ready(self):
setup_signals()
22 changes: 22 additions & 0 deletions tock/organizations/signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import logging

from django.db.models.signals import pre_save

logger = logging.getLogger('tock-organizations')


def organization_creation(sender, instance=None, **kwargs):
if instance is not None and instance.pk is None:
logger.info(
f'Creating Organization for {instance}.'
)


def setup_signals():
from .models import Organization

pre_save.connect(
organization_creation,
sender=Organization,
dispatch_uid="organizations_organization_creation"
)
8 changes: 8 additions & 0 deletions tock/projects/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.apps import AppConfig
from .signals import setup_signals

class ProjectsAppConfig(AppConfig):
name = "projects"

def ready(self):
setup_signals()
Loading

0 comments on commit aeea1ed

Please sign in to comment.