Skip to content
This repository has been archived by the owner on Feb 23, 2020. It is now read-only.

Commit

Permalink
#169 Enable TableEditor's search by a Product.mark field. (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
chelovek-18 authored and duker33 committed Jul 7, 2018
1 parent 7fda6d8 commit f5c76c4
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
19 changes: 17 additions & 2 deletions front/js/admin.es6
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ const customColModels = [
name: 'mark',
label: 'марка',
editable: true,
width: 80,
width: 40,
search: true,
},
{
name: 'specification',
Expand Down Expand Up @@ -227,8 +228,22 @@ const toggleFilterBtnText = {
hide: 'Скрыть фильтры',
};

class STBTableEditor extends TableEditor {
constructor (colModel, dialogs) {
super(colModel, dialogs);

this.filterFields = [
'name',
'mark',
'category_name',
'price',
];

}
}

new AdminCommonPlugins(); // Ignore ESLintBear (no-undef)
new AdminSidebar(); // Ignore ESLintBear (no-undef)
const stbFilters = new TableEditorFilters(toggleFilterBtnText); // Ignore ESLintBear (no-undef)
const stbColModel = new TableEditorColModel(customColModels, stbFilters); // Ignore ESLintBear (no-undef)
new TableEditor(stbColModel); // Ignore ESLintBear (no-undef)
new STBTableEditor(stbColModel); // Ignore ESLintBear (no-undef)
35 changes: 35 additions & 0 deletions stroyprombeton/tests/tests_selenium_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,3 +549,38 @@ def test_new_entity_creation(self):

# We are able to change newly created entity:
self.test_edit_product_name()

def get_field_from_jqgrid(self, fieldname, row):
tr = (
self.browser
.find_elements_by_class_name('jqgrow')[row]
)

return next(
td.text for td in tr.find_elements_by_tag_name('td')
if td.get_attribute('aria-describedby') == f'jqGrid_{fieldname}'
)

def test_mark_search_on_table_editor(self):
"""
Search mark on table editor.
@todo #215 Fill two Product's mark fields for fixtures and fix a related test
"""
self.refresh_table_editor_page()

mark_in_first_row_table = self.get_field_from_jqgrid('mark', 0).strip()

# mark_from_db = Product.objects.exclude(mark="").first().mark.strip()
# second_mark_from_db = Product.objects.exclude(mark="").exclude(mark=mark_from_db).first().mark.strip()
# if mark_in_first_row_table == mark_from_db:
# mark_from_db = second_mark_from_db

# search_field = self.browser.find_element_by_id('search-field')
# search_field.send_keys(mark_from_db)
# wait(2)
# mark_found = self.get_field_from_jqgrid('mark', 0).strip()

# self.assertNotEqual(mark_in_first_row_table, mark_found)

# self.assertEqual(mark_found, mark_from_db)

1 comment on commit f5c76c4

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on f5c76c4 Jul 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to retrieve PDD puzzles from the code base and submit them to GitHub. If you think that it's a bug on our side, please submit it to yegor256/0pdd:

set -x && set -e && set -o pipefail && cd /tmp/0pdd20180707-4-6ujxqw/fidals/stroyprombeton && git config --local core.autocrlf false && git reset origin/master --hard --quiet && git clean --force -d && git fetch --quiet && git checkout master && git rebase --abort || true && git stash && git...

Please, copy and paste this stack trace to GitHub:

Exec::Error
set -x && set -e && set -o pipefail && cd /tmp/0pdd20180707-4-6ujxqw/fidals/stroyprombeton && git config --local core.autocrlf false && git reset origin/master --hard --quiet && git clean --force -d && git fetch --quiet && git checkout master && git rebase --abort || true && git stash && git rebase --strategy-option=theirs origin/master [1]:
bash: warning: setlocale: LC_ALL: cannot change locale (UTF-8)
+ set -e
+ set -o pipefail
+ cd /tmp/0pdd20180707-4-6ujxqw/fidals/stroyprombeton
+ git config --local core.autocrlf false
+ git reset origin/master --hard --quiet
+ git clean --force -d
+ git fetch --quiet
+ git checkout master
Already on 'master'
+ git rebase --abort
No rebase in progress?
+ true
+ git stash
+ git rebase --strategy-option=theirs origin/master
fatal: Could not parse object 'fe47adf71cbca22933d72ef618dcb3fc5ce634fa^'
Unknown exit code (128) from command: git-merge-recursive fe47adf71cbca22933d72ef618dcb3fc5ce634fa^ -- HEAD fe47adf71cbca22933d72ef618dcb3fc5ce634fa

Your branch and 'origin/master' have diverged,
and have 1 and 247 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)
No local changes to save
First, rewinding head to replay your work on top of it...

/app/objects/exec.rb:60:in `block (2 levels) in run'
/app/vendor/ruby-2.3.3/lib/ruby/2.3.0/open3.rb:205:in `popen_run'
/app/vendor/ruby-2.3.3/lib/ruby/2.3.0/open3.rb:95:in `popen3'
/app/objects/exec.rb:54:in `block in run'
/app/vendor/ruby-2.3.3/lib/ruby/2.3.0/timeout.rb:91:in `block in timeout'
/app/vendor/ruby-2.3.3/lib/ruby/2.3.0/timeout.rb:33:in `block in catch'
/app/vendor/ruby-2.3.3/lib/ruby/2.3.0/timeout.rb:33:in `catch'
/app/vendor/ruby-2.3.3/lib/ruby/2.3.0/timeout.rb:33:in `catch'
/app/vendor/ruby-2.3.3/lib/ruby/2.3.0/timeout.rb:106:in `timeout'
/app/objects/exec.rb:53:in `run'
/app/objects/git_repo.rb:111:in `pull'
/app/objects/git_repo.rb:75:in `push'
/app/objects/job.rb:36:in `proceed'
/app/objects/job_starred.rb:33:in `proceed'
/app/objects/job_recorded.rb:32:in `proceed'
/app/objects/job_emailed.rb:35:in `proceed'
/app/objects/job_commiterrors.rb:36:in `proceed'
/app/objects/job_detached.rb:48:in `exclusive'
/app/objects/job_detached.rb:36:in `block in proceed'
/app/objects/job_detached.rb:36:in `fork'
/app/objects/job_detached.rb:36:in `proceed'
/app/0pdd.rb:342:in `block in <top (required)>'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1634:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1634:in `block in compile!'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:992:in `block (3 levels) in route!'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1011:in `route_eval'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:992:in `block (2 levels) in route!'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1039:in `block in process_route'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1037:in `catch'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1037:in `process_route'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:990:in `block in route!'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:989:in `each'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:989:in `route!'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1096:in `block in dispatch!'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1075:in `block in invoke'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1075:in `catch'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1075:in `invoke'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1093:in `dispatch!'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:924:in `block in call!'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1075:in `block in invoke'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1075:in `catch'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1075:in `invoke'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:924:in `call!'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:913:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.1/lib/rack/protection/xss_header.rb:18:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.1/lib/rack/protection/path_traversal.rb:16:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.1/lib/rack/protection/json_csrf.rb:26:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.1/lib/rack/protection/base.rb:50:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.1/lib/rack/protection/base.rb:50:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.1/lib/rack/protection/frame_options.rb:31:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.5/lib/rack/logger.rb:15:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.5/lib/rack/common_logger.rb:33:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:231:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:224:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.5/lib/rack/head.rb:12:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.5/lib/rack/method_override.rb:22:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:194:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1957:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1501:in `block in call'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1728:in `synchronize'
/app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.1/lib/sinatra/base.rb:1501:in `call'
/app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.5/lib/rack/handler/webrick.rb:86:in `service'
/app/vendor/ruby-2.3.3/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `service'
/app/vendor/ruby-2.3.3/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run'
/app/vendor/ruby-2.3.3/lib/ruby/2.3.0/webrick/server.rb:296:in `block in start_thread'

Please sign in to comment.