Skip to content

Commit

Permalink
chore: cleanup bricr-dev merge
Browse files Browse the repository at this point in the history
chore: tweaks for flake8
  • Loading branch information
macintoshpie committed Apr 16, 2020
1 parent e123920 commit 0c7643e
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 371 deletions.
1 change: 1 addition & 0 deletions seed/building_sync/tests/test_buildingsync_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from django.urls import reverse
from django.utils import timezone

from config.settings.common import BASE_DIR
from seed.landing.models import SEEDUser as User
from seed.models import (
PropertyView,
Expand Down
348 changes: 0 additions & 348 deletions seed/data_importer/tasks.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions seed/data_importer/tests/integration/test_data_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,13 @@ def test_map_all_models_xml(self):
self.assertEqual(ps.count(), 1)

# verify the property view, scenario and meter data were created
pv = PropertyView.objects.filter(state=ps)
pv = PropertyView.objects.filter(state=ps[0])
self.assertEqual(pv.count(), 1)

meters = Meter.objects.filter(property=pv[0].property)
self.assertEqual(meters.count(), 6)

scenario = Scenario.objects.filter(property_state=ps)
scenario = Scenario.objects.filter(property_state=ps[0])
self.assertEqual(scenario.count(), 3)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class Migration(migrations.Migration):

dependencies = [
('seed', '0110_auto_20200303_1428'),
('seed', '0122_auto_20200303_1428'),
]

operations = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class Migration(migrations.Migration):

dependencies = [
('seed', '0111_auto_20200324_1424'),
('seed', '0123_auto_20200324_1424'),
]

operations = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ angular.module('BE.seed.controller.data_upload_modal', [])
}
}, function (data) {
$log.error(data.message);
if (data.hasOwnProperty('stacktrace')) $log.error(data.stacktrace);
if (_.has(data, 'stacktrace')) $log.error(data.stacktrace);
$scope.step_12_error_message = data.data ? data.data.message : data.message;
$scope.step.number = 12;
}, $scope.uploader);
Expand Down
41 changes: 25 additions & 16 deletions seed/static/seed/js/controllers/mapping_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ angular.module('BE.seed.controller.mapping', [])
'$translate',
'i18nService', // from ui-grid
'simple_modal_service',
'$state',
'Notification',
function (
$scope,
Expand Down Expand Up @@ -57,7 +56,6 @@ angular.module('BE.seed.controller.mapping', [])
$translate,
i18nService,
simple_modal_service,
$state,
Notification
) {
$scope.presets = [
Expand Down Expand Up @@ -333,23 +331,38 @@ angular.module('BE.seed.controller.mapping', [])
$scope.duplicates_present = duplicates_present;
};

const get_col_from_suggestion = (name) => {
if ($scope.import_file.source_type === "BuildingSync Raw") {
const suggestion = $scope.suggested_mappings[name];

return {
name: name,
suggestion_column_name: suggestion[1],
suggestion_table_name: suggestion[0],
raw_data: _.map(first_five_rows_payload.first_five_rows, name)
};
}

const suggestion = _.find($scope.current_preset.mappings, {from_field: name}) || {};

return {
from_units: suggestion.from_units,
name: name,
raw_data: _.map(first_five_rows_payload.first_five_rows, name),
suggestion: suggestion.to_field,
suggestion_column_name: suggestion.to_field,
suggestion_table_name: suggestion.to_table_name
};
}

/**
* initialize_mappings: prototypical inheritance for all the raw columns
* called by init()
*/
$scope.initialize_mappings = function () {
$scope.mappings = [];
_.forEach($scope.raw_columns, function (name) {
var suggestion = _.find($scope.current_preset.mappings, {from_field: name}) || {};

var col = {
from_units: suggestion.from_units,
name: name,
raw_data: _.map(first_five_rows_payload.first_five_rows, name),
suggestion: suggestion.to_field,
suggestion_column_name: suggestion.to_field,
suggestion_table_name: suggestion.to_table_name
};
let col = get_col_from_suggestion(name);

var match;
if (col.suggestion_table_name === 'PropertyState') {
Expand All @@ -367,10 +380,6 @@ angular.module('BE.seed.controller.mapping', [])
col.suggestion = match.display_name;
} else if ($scope.import_file.source_type === "BuildingSync Raw") {
col.suggestion = $filter('titleCase')(col.suggestion_column_name);
} else {
// No match, generate title-cased name
col.suggestion = $filter('titleCase')(col.suggestion_column_name);
col.suggestion_column_name = null;
}

$scope.mappings.push(col);
Expand Down
9 changes: 9 additions & 0 deletions seed/static/seed/js/seed.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,12 @@ SEED_app.config(['stateHelperProvider', '$urlRouterProvider', '$locationProvider
templateUrl: static_url + 'seed/partials/mapping_xml.html',
controller: 'mapping_controller',
resolve: {
column_mapping_presets_payload: ['column_mappings_service', 'user_service', function (column_mappings_service, user_service) {
var organization_id = user_service.get_organization().id;
return column_mappings_service.get_column_mapping_presets_for_org(organization_id).then(function (response) {
return response.data;
});
}],
import_file_payload: ['dataset_service', '$stateParams', function (dataset_service, $stateParams) {
var importfile_id = $stateParams.importfile_id;
return dataset_service.get_import_file(importfile_id);
Expand All @@ -597,6 +603,9 @@ SEED_app.config(['stateHelperProvider', '$urlRouterProvider', '$locationProvider
cycles: ['cycle_service', function (cycle_service) {
return cycle_service.get_cycles();
}],
matching_criteria_columns_payload: ['organization_service', 'user_service', function (organization_service, user_service) {
return organization_service.matching_criteria_columns(user_service.get_organization().id);
}],
auth_payload: ['auth_service', '$q', 'user_service', function (auth_service, $q, user_service) {
var organization_id = user_service.get_organization().id;
return auth_service.is_authorized(organization_id, ['requires_member'])
Expand Down
2 changes: 0 additions & 2 deletions seed/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import time
from unittest import skip

from datetime import date

from django.urls import reverse_lazy, reverse
from django.test import TestCase
from django.utils import timezone
Expand Down

0 comments on commit 0c7643e

Please sign in to comment.