Skip to content

Commit

Permalink
fixed merge conflict in map file
Browse files Browse the repository at this point in the history
  • Loading branch information
mmclark committed Dec 17, 2015
2 parents dd2abdc + 477fb20 commit 5ef0814
Show file tree
Hide file tree
Showing 15 changed files with 141 additions and 154 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
sudo: false

cache:
directories:
- node_modules
- seed/static/vendors/bower_components
- $HOME/.pip-cache/

language: python
Expand Down Expand Up @@ -38,4 +42,3 @@ script:

after_script:
- coveralls

2 changes: 1 addition & 1 deletion seed/static/seed/css/style.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion seed/static/seed/css/style.css.map

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions seed/static/seed/js/controllers/building_list_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,20 @@ angular.module('BE.seed.controller.building_list', [])
* SEARCH CODE
*/

$scope.do_update_buildings_filters = function(){
/* Called by 'Update Filters' click in buildings list UI */
$scope.do_update_buildings_filters = function(){
$scope.search.deselect_all_buildings();
refresh_search();
};

$scope.do_update_projects_filters = function(){
/* Called by 'Update Filters' click in projects buildings list UI */
$scope.do_update_project_buildings_filters = function(){
$scope.search.deselect_all_buildings();
refresh_search();
};

/* private function to refresh search, called by UI event handlers
or internal methods */
var refresh_search = function() {
$scope.search.search_buildings();
};
Expand Down
1 change: 1 addition & 0 deletions seed/static/seed/js/controllers/menu_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ angular.module('BE.seed.controller.menu', [])
organization_service.get_organizations().then(function (data) {
// resolve promise
$scope.organizations_count = data.organizations.length;
$scope.menu.user.organizations = data.organizations;
});
};
init();
Expand Down
14 changes: 12 additions & 2 deletions seed/static/seed/js/services/label_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ angular.module('BE.seed.service.label',
$http({
method: 'POST',
'url': window.BE.urls.label_list,
'data': label
'data': label,
'params': {
'organization_id': user_service.get_organization().id
}
}).success(function(data, status, headers, config) {
if(data){
data = update_label_w_local_props(data);
Expand Down Expand Up @@ -129,6 +132,9 @@ angular.module('BE.seed.service.label',
method: 'PUT',
'url': window.BE.urls.label_list + label.id + '/',
'data': label,
'params': {
'organization_id': user_service.get_organization().id
}
}).success(function(data, status, headers, config) {
if(data){
data = update_label_w_local_props(data);
Expand All @@ -153,6 +159,9 @@ angular.module('BE.seed.service.label',
$http({
method: 'DELETE',
'url': window.BE.urls.label_list + label.id + '/',
'params': {
'organization_id': user_service.get_organization().id
}
}).success(function(data, status, headers, config) {
defer.resolve(data);
}).error(function(data, status, headers, config) {
Expand Down Expand Up @@ -188,7 +197,8 @@ angular.module('BE.seed.service.label',
'url': window.BE.urls.update_building_labels,
'params': _.extend({
'selected_buildings' : selected_buildings,
'select_all_checkbox': select_all_checkbox
'select_all_checkbox': select_all_checkbox,
'organization_id': user_service.get_organization().id
}, search_params),
'data': {
'add_label_ids': add_label_ids,
Expand Down
13 changes: 13 additions & 0 deletions seed/static/seed/js/services/search_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,19 @@ angular.module('BE.seed.service.search', [])
* end checkbox logic
*/

/** deselect_all_buildings: Force a deselection of all buildings
*
*/
search_service.deselect_all_buildings = function() {
var len = this.buildings.length;
for (var bldg_index = 0; bldg_index < len; bldg_index++) {
this.buildings[bldg_index].checked = false;
}
this.selected_buildings = [];
this.select_all_checkbox = false;
};


/**
* table columns logic
*/
Expand Down
4 changes: 2 additions & 2 deletions seed/static/seed/partials/mapping.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ <h1>Data Mapping &amp; Validation ({$ import_file.name $})</h1>
</div>
<div class="section_header_container" ng-show="show_mapped_buildings">
<div class="section_header fixed_height">
<div class="left section_action_container">
<div class="left_40 section_action_container">
<button type="button" class="btn btn-primary" ng-click="review_mappings=false; show_mapped_buildings=false"><i class="fa fa-chevron-left"></i> Back to Mapping</button>
<div class="btn-group" style="margin-left:20px;">
<button type="button"
Expand All @@ -183,7 +183,7 @@ <h1>Data Mapping &amp; Validation ({$ import_file.name $})</h1>
</button>
</div>
</div>
<div class="right_wide section_action_container section_action_btn">
<div class="right_60 section_action_container section_action_btn">
<button type="button" class="btn btn-default" ng-click="open_cleansing_modal()"><i class="fa fa-exclamation-triangle"></i>Data Cleansing Results</button>
<button type="button" class="btn btn-default" ng-click="open_edit_columns_modal()"><i class="fa fa-columns"></i>View/Hide Columns</button>
<a ng-href="#/data/mapping/{$ import_file.id $}"><button id="save-mapping" type="button" class="pull-right btn btn-primary" ng-click="open_data_upload_modal(import_file.dataset)" ng-hide="import_file.matching_done">Save Mappings</button></a>
Expand Down
4 changes: 2 additions & 2 deletions seed/static/seed/partials/project_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h1><i class="fa fa-folder-o"></i> {$ project.name $} ({$ search.number_matchin
</div>
<div class="section_header_container">
<div class="section_header fixed_height">
<div class="left section_action_container">
<div class="left_40 section_action_container">
<div class="check_action">
<div uib-dropdown class="btn-group" ng-style="nothing_selected_cursor()">
<button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" ng-disabled="nothing_selected()">
Expand All @@ -41,7 +41,7 @@ <h1><i class="fa fa-folder-o"></i> {$ project.name $} ({$ search.number_matchin
<div class="btn-group" style="margin-left:20px;">
<button type="button"
class="btn btn-primary btn-sm"
ng-click="do_update_projects_filters()" >
ng-click="do_update_project_buildings_filters()" >
Update Filters
</button>
</div>
Expand Down
12 changes: 10 additions & 2 deletions seed/static/seed/scss/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -663,9 +663,9 @@ a:not([href]) {
float: left;
width: 25%;
}
&.left_half {
&.left_40 {
float: left;
width: 50%;
width: 40%;
}
&.left_wide {
float: left;
Expand Down Expand Up @@ -693,6 +693,14 @@ a:not([href]) {
padding-right: 0;
}
}
&.right_60 {
float: right;
width: 60%;
text-align: right;
button {
margin-left: 7px;
}
}
&.right_wide {
float: right;
width: 75%;
Expand Down
92 changes: 31 additions & 61 deletions seed/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import string
import operator
import traceback
import itertools
from _csv import Error
from dateutil import parser
from django.core.mail import send_mail
Expand Down Expand Up @@ -476,6 +475,18 @@ def result_fn(model, key, value):
return result_fn


def _normalize_tax_lot_id(value):
return value.strip().lstrip('0').upper().replace(
'-', ''
).replace(
' ', ''
).replace(
'/', ''
).replace(
'\\', ''
)


@shared_task
def map_row_chunk(chunk, file_pk, source_type, prog_key, increment, *args, **kwargs):
"""Does the work of matching a mapping to a source type and saving
Expand Down Expand Up @@ -519,9 +530,9 @@ def map_row_chunk(chunk, file_pk, source_type, prog_key, increment, *args, **kwa

for row in chunk:
model = mapper.map_row(
row=row,
mapping=mapping,
model_class=BuildingSnapshot,
row,
mapping,
BuildingSnapshot,
cleaner=map_cleaner,
concat=concats,
apply_columns=apply_columns,
Expand All @@ -530,70 +541,21 @@ def map_row_chunk(chunk, file_pk, source_type, prog_key, increment, *args, **kwa
**kwargs
)

if model.tax_lot_id:
model.tax_lot_id = _normalize_tax_lot_id(model.tax_lot_id)

model.import_file = import_file
model.source_type = save_type
model.clean()
model.super_organization = import_file.import_record.super_organization

# Tax Lot ID can potentially contain multiple deliniated values. These
# need to be split and normalized.
tax_lot_ids = _extract_tax_lot_ids(model.tax_lot_id)
model.tax_lot_id, additional_ids = tax_lot_ids[0], tax_lot_ids[1:]
model.save()

# If there is more than a single ID, duplicate the building.
for tax_lot_id in additional_ids:
model.id = None
model.tax_lot_id = tax_lot_id
model.save()

try:
if model:
# Make sure that we've saved all of the extra_data column names
save_column_names(model, mapping=mapping)
except NameError:
# There were no rows in the chunk.
pass

increment_cache(prog_key, increment)


def _normalize_tax_lot_id(value):
return value.strip().lstrip('0').upper().replace(
'-', ''
).replace(
' ', ''
).replace(
'/', ''
).replace(
'\\', ''
)


def split(value, delimiters):
"""
Given a string, and an iterable of delimeters, return an iterable
containing all of the substrings that were deliniated by the delimeters.
"""
_value = [str(value)]
for delimiter in delimiters:
_value = tuple(itertools.chain.from_iterable((
v.split(delimiter) for v in _value
)))
return _value


def _extract_tax_lot_ids(value):
if not value:
return [value]

tax_lot_ids = [
_normalize_tax_lot_id(tax_lot_id)
for tax_lot_id in split(value, ",;")
if tax_lot_id
]
return tax_lot_ids


@shared_task
@lock_and_track
def _map_data(file_pk, *args, **kwargs):
Expand Down Expand Up @@ -1036,17 +998,25 @@ def get_canonical_id_matches(org_id, pm_id, tax_id, custom_id):
params = []
can_snapshots = get_canonical_snapshots(org_id)
if pm_id:
params.append(Q(pm_property_id=pm_id) | Q(pm_property_id__isnull=True))
params.append(Q(pm_property_id=pm_id))
params.append(Q(tax_lot_id=pm_id))
params.append(Q(custom_id_1=pm_id))
if tax_id:
params.append(Q(tax_lot_id=tax_id) | Q(tax_lot_id__isnull=True))
params.append(Q(pm_property_id=tax_id))
params.append(Q(tax_lot_id=tax_id))
params.append(Q(custom_id_1=tax_id))
if custom_id:
params.append(Q(custom_id_1=custom_id) | Q(custom_id_1__isnull=True))
params.append(Q(pm_property_id=custom_id))
params.append(Q(tax_lot_id=custom_id))
params.append(Q(custom_id_1=custom_id))

if not params:
# Return an empty QuerySet if we don't have any params.
return can_snapshots.none()

canonical_matches = can_snapshots.filter(*params)
canonical_matches = can_snapshots.filter(
reduce(operator.or_, params)
)

return canonical_matches

Expand Down
3 changes: 3 additions & 0 deletions seed/tests/functional/test_firefox.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import time
import json
import os
import unittest

from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from selenium import webdriver
from selenium.common.exceptions import NoSuchAttributeException, StaleElementReferenceException, NoSuchElementException
Expand All @@ -21,6 +23,7 @@ def tearDownClass(cls):
cls.selenium.quit()
super(LogIn, cls).tearDownClass()

@unittest.skipIf(os.environ.get("TRAVIS") == "true", "https://github.com/SEED-platform/seed/issues/531")
def test_login(self):

# Test LogIn Process
Expand Down

0 comments on commit 5ef0814

Please sign in to comment.