Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanandrews committed Sep 17, 2020
2 parents 9e4c2b5 + eef1e67 commit e6557f7
Show file tree
Hide file tree
Showing 435 changed files with 83,480 additions and 2,001 deletions.
30 changes: 24 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,24 @@
# You should have received a copy of the GNU General Public License
# along with ooicgsn-roundabout in the COPYING.md file at the project root.
# If not, see <http://www.gnu.org/licenses/>.
#

version: 2
#

workflows:
version: 2
test:
main:
jobs:
- build
- build:
filters:
branches:
only:
- develop
- automated_tests

version: 2
jobs:
build:
machine: true
machine:
image: ubuntu-1604:202007-01
steps:
- checkout
- run:
Expand Down Expand Up @@ -67,6 +72,19 @@ jobs:
command: >-
docker-compose --file local.yml run --rm django \
python manage.py test
- run:
name: Running Automated tests
command: >-
docker-compose -f local.yml run --rm tests \
sh -c "until curl -Is http://localhost:8000; do echo 'sleeping'; sleep 10; done &&
google-chrome --version && chromedriver --version &&
firefox --version && geckodriver --version &&
nodejs -v &&
./RunAllTests-Chrome-Linux.bat &&
./RunAllTests-Firefox-Linux.bat"
- run:
name: Stopping Docker application
command: >-
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ Session.vim
# Auto-generated tag files
tags

# Pycharm IDE files
.idea

# database backups
*.sql.gz

### Project template

Expand Down
1 change: 0 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Roundabout DB - OOI Parts and Inventory Web Application

Django application to manage Part, Location, and Assembly Templates, and Inventory tracking for OOI-CGSN arrays. Uses PostgreSQL database.

:Current Version: 1.3.2
:License: GPL v2.0 or later


Expand Down
27 changes: 27 additions & 0 deletions compose/local/tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM ubuntu:18.04
RUN apt-get update && apt-get install -y --no-install-recommends apt-utils
RUN apt-get install curl -y && apt-get install npm -y
# Tools for Circleci debugging
RUN apt-get install iputils-ping -y && apt-get install net-tools -y

RUN apt-get install -y wget && apt install -y unzip

# At Circleci root dir
COPY ./tests/*.bat /tests/
COPY ./tests/*.js /tests/

RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get install -y nodejs
RUN npm install selenium-webdriver
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && apt install -y ./google-chrome-stable_current_amd64.deb
RUN wget https://chromedriver.storage.googleapis.com/85.0.4183.83/chromedriver_linux64.zip && unzip -o chromedriver_linux64.zip -d/usr/local/bin
RUN apt install -y firefox && apt install -y firefox-geckodriver

RUN chmod +x /tests/RunAllTests-Chrome-Linux.bat
RUN sed -i 's/\r//' /tests/RunAllTests-Chrome-Linux.bat

RUN chmod +x /tests/RunAllTests-Firefox-Linux.bat
RUN sed -i 's/\r//' /tests/RunAllTests-Firefox-Linux.bat

WORKDIR /tests

8 changes: 7 additions & 1 deletion config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
'mptt', # Tree structures in database
'django_summernote', #WYSIWYG
'bootstrap_datepicker_plus', # Date Picker
'import_export', # simple model import/export using admin interface
'django_tables2', # interactive tables views
'django_tables2_column_shifter', # show/hide tables2 columns
]
Expand All @@ -110,8 +111,11 @@
'roundabout.userdefinedfields',
'roundabout.assemblies',
'roundabout.builds',
'roundabout.cruises',
'roundabout.calibrations',
'roundabout.configs_constants',
'roundabout.search',
'roundabout.exports',
]
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
Expand Down Expand Up @@ -364,5 +368,7 @@
'SLIDING_TOKEN_REFRESH_LIFETIME': timedelta(days=1),
}

# import-export settings
IMPORT_EXPORT_USE_TRANSACTIONS = True
# Allow for larger CoefficientValue formset handling
DATA_UPLOAD_MAX_NUMBER_FIELDS = 10000
DATA_UPLOAD_MAX_NUMBER_FIELDS = 10000
4 changes: 3 additions & 1 deletion config/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
# Copyright (C) 2019-2020 Woods Hole Oceanographic Institution
#
# This file is part of the Roundabout Database project ("RDB" or
# This file is part of the Roundabout Database project ("RDB" or
# "ooicgsn-roundabout").
#
# ooicgsn-roundabout is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -55,8 +55,10 @@
path('userdefinedfields/', include('roundabout.userdefinedfields.urls', namespace='userdefinedfields')),
path('assemblies/', include('roundabout.assemblies.urls', namespace='assemblies')),
path('builds/', include('roundabout.builds.urls', namespace='builds')),
path('cruises/', include('roundabout.cruises.urls', namespace='cruises')),
path('reports/', include('roundabout.reports.urls', namespace='reports')),
path('search/', include('roundabout.search.urls', namespace='search')),
path('export/', include('roundabout.exports.urls', namespace='export')),
path('calibrations/', include('roundabout.calibrations.urls', namespace='calibrations')),
path('configs_constants/', include('roundabout.configs_constants.urls', namespace='configs_constants')),
# API urls
Expand Down
11 changes: 10 additions & 1 deletion local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ services:
- postgres
volumes:
- .:/app
env_file:
env_file:
- ./.envs/.local/.django
- ./.envs/.local/.postgres
ports:
Expand All @@ -44,6 +44,15 @@ services:
networks:
- roundabout-network

tests:
build:
context: .
dockerfile: ./compose/local/tests/Dockerfile
image: roundabout_production_tests
depends_on:
- django
network_mode: "service:django"

postgres:
build:
context: .
Expand Down
3 changes: 2 additions & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pytz==2018.7 # https://github.com/stub42/pytz
python-slugify==1.2.6 # https://github.com/un33k/python-slugify
Pillow==5.3.0 # https://github.com/python-pillow/Pillow
argon2-cffi==18.3.0 # https://github.com/hynek/argon2_cffi
argon2-cffi==20.1.0 # https://github.com/hynek/argon2_cffi
redis>=2.10.6, < 3 # pyup: < 3 # https://github.com/antirez/redis

# Django
Expand All @@ -27,6 +27,7 @@ sigfig==1.1.8 #https://pypi.org/project/sigfig/
django-tables2==2.2.1 # https://github.com/jieter/django-tables2
tablib==1.1 # https://github.com/jazzband/tablib for exporting/downloading tables2/tabular data
django-tables2-column-shifter==0.5.2 # for showing/hiding columns for tables2
django-import-export==2.0.2

# Sentry error logging
sentry-sdk==0.14.3
3 changes: 3 additions & 0 deletions roundabout/admintools/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
class ImportInventoryForm(forms.Form):
document = forms.FileField()

class ImportCalibrationForm(forms.Form):
document = forms.FileField()


class PrinterForm(forms.ModelForm):

Expand Down
2 changes: 2 additions & 0 deletions roundabout/admintools/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
app_name = 'admintools'
urlpatterns = [
path('sentry-debug/', views.trigger_error),
#Import Calibrations
path('import/calibrations/upload/', view=views.ImportCalibrationsUploadView.as_view(), name='import_calibrations_upload'),
# Printers
path('printers/', view=views.PrinterListView.as_view(), name='printers_home'),
path('printers/add/', view=views.PrinterCreateView.as_view(), name='printers_add'),
Expand Down
24 changes: 23 additions & 1 deletion roundabout/admintools/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from django.views.generic import View, DetailView, ListView, RedirectView, UpdateView, CreateView, DeleteView, TemplateView, FormView
from django.contrib.auth.mixins import LoginRequiredMixin, PermissionRequiredMixin

from .forms import PrinterForm, ImportInventoryForm
from .forms import PrinterForm, ImportInventoryForm, ImportCalibrationForm
from .models import *
from roundabout.userdefinedfields.models import FieldValue, Field
from roundabout.inventory.models import Inventory, Action
Expand All @@ -45,6 +45,28 @@
def trigger_error(request):
division_by_zero = 1 / 0


# Calibrations Github CSV file uploader
# Upload formview for Inventory Bulk upload
class ImportCalibrationsUploadView(LoginRequiredMixin, FormView):
form_class = ImportCalibrationForm
template_name = 'admintools/import_calibrations_upload_form.html'

def form_valid(self, form):
csv_file = self.request.FILES['document']
print(csv_file)
# Set up the Django file object for CSV DictReader
csv_file.seek(0)
reader = csv.DictReader(io.StringIO(csv_file.read().decode('utf-8')))

for row in reader:
print(row)

return super(ImportCalibrationsUploadView, self).form_valid(form)

def get_success_url(self):
return reverse('admintools:import_inventory_upload_success', )

# Bulk Inventory Import Functions
# ------------------------------------------
# Create a blank CSV template for user to download and populate
Expand Down
2 changes: 1 addition & 1 deletion roundabout/assemblies/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Meta:
get_latest_by = 'created_at'

def __str__(self):
return '%s - %s' % (self.revision_code, self.assembly.name)
return 'Revision %s - %s' % (self.revision_code, self.assembly.name)

# method to set the object_type variable to send to Javascript AJAX functions
def get_object_type(self):
Expand Down
2 changes: 2 additions & 0 deletions roundabout/assemblies/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ class AssemblyTypeDeleteView(LoginRequiredMixin, PermissionRequiredMixin, Delete
permission_required = 'assemblies.delete_assembly'
redirect_field_name = 'home'


# Direct Detail view for Assembly Types
class AssemblyTypeDetailView(LoginRequiredMixin, DetailView):
model = AssemblyType
Expand All @@ -766,6 +767,7 @@ def post(self, request, *args, **kwargs):
context = self.get_context_data(object=self.object)
return self.render_to_response(context)


# AJAX Views
class AssemblyTypeAjaxDetailView(LoginRequiredMixin, DetailView):
model = AssemblyType
Expand Down
26 changes: 18 additions & 8 deletions roundabout/builds/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from django_summernote.widgets import SummernoteInplaceWidget, SummernoteWidget

from .models import Build, BuildAction, BuildSnapshot, PhotoNote
from roundabout.inventory.models import Deployment, DeploymentAction
from roundabout.inventory.models import Deployment, DeploymentAction, Action
from roundabout.locations.models import Location
# Get the app label names from the core utility functions
from roundabout.core.utils import set_app_labels
Expand Down Expand Up @@ -108,17 +108,22 @@ class BuildActionPhotoNoteForm(forms.ModelForm):
photo_ids = forms.CharField(required=False, widget=forms.HiddenInput())

class Meta:
model = BuildAction
fields = ['detail', 'build', 'location']
model = Action
fields = ['detail', 'build', 'location', 'object_type']
labels = {
'detail': 'Add a Note',
}
widgets = {
'build': forms.HiddenInput(),
'location': forms.HiddenInput(),
'object_type': forms.HiddenInput(),
'detail': SummernoteWidget(),
}

def __init__(self, *args, **kwargs):
super(BuildActionPhotoNoteForm, self).__init__(*args, **kwargs)
self.initial['object_type'] = Action.BUILD


class BuildActionPhotoUploadForm(forms.ModelForm):

Expand Down Expand Up @@ -171,12 +176,13 @@ class DeploymentForm(forms.ModelForm):

class Meta:
model = Deployment
fields = ['location', 'deployment_number', 'build', 'deployed_location']
fields = ['location', 'deployment_number', 'build', 'deployed_location', 'cruise_deployed']

labels = {
'location': 'Current Location',
'deployment_number': '%s Number' % (labels['label_deployments_app_singular']),
'deployed_location': 'Final %s Location' % (labels['label_deployments_app_singular']),
'cruise_deployed': 'Cruise Deployed On',
}

widgets = {
Expand All @@ -201,10 +207,11 @@ class DeploymentActionBurninForm(forms.ModelForm):

class Meta:
model = Deployment
fields = ['location', 'deployed_location']
fields = ['location', 'deployed_location', 'cruise_deployed']
labels = {
'location': 'Select Location for Burn In',
'deployed_location': 'Final %s Location' % (labels['label_deployments_app_singular']),
'cruise_deployed': 'Cruise Deployed On',
}

# Add custom date field to allow user to pick date for the Action
Expand All @@ -225,9 +232,10 @@ class DeploymentActionDeployForm(forms.ModelForm):

class Meta:
model = Deployment
fields = ['location',]
fields = ['location', 'cruise_deployed']
labels = {
'location': '%s Location' % (labels['label_deployments_app_singular']),
'cruise_deployed': 'Cruise Deployed On',
}

# Add custom date field to allow user to pick date for the Action record
Expand Down Expand Up @@ -273,9 +281,10 @@ class DeploymentActionDetailsForm(forms.ModelForm):

class Meta:
model = Deployment
fields = ['location',]
fields = ['location', 'cruise_deployed']
labels = {
'location': '%s Location' % (labels['label_deployments_app_singular']),
'cruise_deployed': 'Cruise Deployed On',
}

# Add custom date field to allow user to pick date for the Action record
Expand Down Expand Up @@ -320,9 +329,10 @@ class DeploymentActionRecoverForm(forms.ModelForm):

class Meta:
model = Deployment
fields = ['location',]
fields = ['location', 'cruise_recovered']
labels = {
'location': 'Select Location to recover %s to:' % (labels['label_deployments_app_singular']),
'cruise_recovered': 'Cruise Recovered On'
}

# Add custom date field to allow user to pick date for the Action record
Expand Down
Loading

0 comments on commit e6557f7

Please sign in to comment.