Skip to content

Commit

Permalink
getFields; empty multiple choice and continue button field; font awes…
Browse files Browse the repository at this point in the history
…ome; github branch and commit; ask_number DAObject error; sql ping fix
  • Loading branch information
jhpyle committed May 4, 2020
1 parent 2f77d49 commit d332929
Show file tree
Hide file tree
Showing 39 changed files with 2,646 additions and 507 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Change Log

## [1.1.23] - 2020-05-03
### Added
- The `getFields()` JavaScript function.
### Changed
- A `question` with `fields` that contains a single multiple choice
field where the choices are empty is not skipped if the `question`
has a `continue button field`.
- The branch and commit are shown in the Packages page of the
Playground when GitHub integration is enabled and the package has a
known presence on GitHub.
- Upgraded Font Awesome to 5.13.0.
### Fixed
- Infinite loop when a list is gathered and `object_type` is set to a
class for which the textual representation or `complete_element` is
pre-defined and a set number of items are to be gathered.
- The `sql ping` feature was not fully implemented.

## [1.1.22] - 2020-04-30
### Changed
- When a item is added to or removed from a group, the `there_are_any`
Expand Down
12 changes: 11 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ you wish to make via issue, email, or any other method with the owner
of this repository before making a change. The best way to contribute
a change is through a pull request.

If you want to add an additional feature, first consider if the
feature could be made available through an [add-on
package](https://docassemble.org/docs/packages.html). If the feature
turns out to be universally useful, it can be incorporated later into
the core code.

## How to modify and test the core docassemble code

For instructions on how to test modificiations to the core code, see the
[workflow for making changes to the core docassemble code](https://docassemble.org/docs/development.html#core).

## How to contribute to the documentation

The documentation is written in GitHub Pages. It is available in the
Expand Down Expand Up @@ -50,4 +61,3 @@ To add a code example to a page of the documentation, include a line
like the following:

{% include side-by-side.html demo="user-logged-in" %}

1 change: 1 addition & 0 deletions docassemble_base/docassemble/base/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,7 @@ def gather(self, number=None, item_object_type=None, minimum=None, complete_attr
#str(self.__getitem__(the_length))
# if item_object_type is not None and complete_attribute is not None:
# getattr(self.__getitem__(the_length), complete_attribute)
the_length = len(self.elements)
if hasattr(self, '_necessary_length'):
del self._necessary_length
elif minimum != 0:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
metadata:
title: List of fields
documentation: "https://docassemble.org/docs/functions.html#js_getFields"
---
question: |
Tell me about your musical tastes.
fields:
- Best band ever: best_band
- Best singer ever: best_singer
- Best composer ever: best_composer
- Best songwriter ever: best_songwriter
- html: |
<a href="#" id="decide_for_me" class="btn btn-success">Decide for me</a>
script: |
<script>
$("#decide_for_me").click(function(){
var fields = getFields();
for (var i = 0; i < fields.length; ++i){
setField(fields[i], 'Carly Simon');
}
return false;
});
</script>
---
mandatory: True
question: |
You like ${ comma_and_list(set([best_band, best_singer, best_composer, best_songwriter])) }.
2 changes: 2 additions & 0 deletions docassemble_base/docassemble/base/data/sources/base-words.yml
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,8 @@
"That screen is already being controlled by another operator": Null
"The author is": Null
"The configuration file was saved.": Null
"The current branch is %s and the current commit is %s.": Null
"The current branch is %s.": Null
"The default project cannot be deleted.": Null
"The document is available in the following formats:": Null
"The file you requested does not exist.": Null
Expand Down
7 changes: 5 additions & 2 deletions docassemble_base/docassemble/base/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -4516,7 +4516,10 @@ def ask(self, user_dict, old_user_dict, the_x, iterators, sought, orig_sought, p
for indexno in range(len(iterators)):
exec(list_of_indices[indexno] + " = " + iterators[indexno], user_dict)
else:
only_empty_fields_exist = True
if hasattr(self, 'fields_saveas'):
only_empty_fields_exist = False
else:
only_empty_fields_exist = True
commands_to_run = list()
for field in self.fields:
if hasattr(field, 'inputtype') and field.inputtype == 'combobox':
Expand Down Expand Up @@ -7838,7 +7841,7 @@ def _fail_with_undefined_error(self, *args, **kwargs):
self._undefined_name
)
else:
hint = '%r has got no attribute %r' % (
hint = '%r has no attribute %r' % (
object_type_repr(self._undefined_obj),
self._undefined_name
)
Expand Down
10 changes: 9 additions & 1 deletion docassemble_webapp/docassemble/webapp/db_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@
def init_flask():
global db
global UserMixin
from flask_sqlalchemy import SQLAlchemy
import docassemble.webapp.database
if docassemble.webapp.database.pool_pre_ping:
from flask_sqlalchemy import SQLAlchemy as _BaseSQLAlchemy
class SQLAlchemy(_BaseSQLAlchemy):
def apply_pool_defaults(self, app, options):
super().apply_pool_defaults(app, options)
options["pool_pre_ping"] = True
else:
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
import flask_user
UserMixin = flask_user.UserMixin
Expand Down
49 changes: 47 additions & 2 deletions docassemble_webapp/docassemble/webapp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3213,7 +3213,7 @@ def get_vars_in_use(interview, interview_status, debug_mode=False, return_json=F
if base_name_info[var]['show']:
names_used.add(var)
names_used = set([i for i in names_used if not extraneous_var.search(i)])
for var in ('_internal', '__object_type'):
for var in ('_internal', '__object_type', '_DAOBJECTDEFAULTDA'):
names_used.discard(var)
for var in interview.mlfields:
names_used.discard(var + '.text')
Expand Down Expand Up @@ -3271,7 +3271,7 @@ def get_vars_in_use(interview, interview_status, debug_mode=False, return_json=F
while '.' in the_var:
the_var = re.sub(r'(.*)\..*$', r'\1', the_var)
implicitly_defined.add(the_var)
for var in ('_internal', '__object_type'):
for var in ('_internal', '__object_type', '_DAOBJECTDEFAULTDA'):
undefined_names.discard(var)
vocab_set.discard(var)
for var in [x for x in undefined_names if x.endswith(']')]:
Expand Down Expand Up @@ -7330,6 +7330,23 @@ def index(action_argument=None):
else{
daTargetDiv = "#dabody";
}
function getFields(){
var allFields = [];
for (var fieldName in daValLookup){
if (daValLookup.hasOwnProperty(fieldName)){
allFields.push(fieldName);
}
}
for (var rawFieldName in daVarLookup){
if (daVarLookup.hasOwnProperty(rawFieldName)){
var fieldName = atob(rawFieldName);
if (allFields.indexOf(fieldName) == -1){
allFields.push(fieldName);
}
}
}
return allFields;
}
function getField(fieldName){
if (typeof daValLookup[fieldName] == "undefined"){
var fieldNameEscaped = btoa(fieldName).replace(/[\\n=]/g, '');//.replace(/(:|\.|\[|\]|,|=)/g, "\\\\$1");
Expand Down Expand Up @@ -11227,6 +11244,23 @@ def observer():
}
}
}
function getFields(){
var allFields = [];
for (var fieldName in daValLookup){
if (daValLookup.hasOwnProperty(fieldName)){
allFields.push(fieldName);
}
}
for (var rawFieldName in daVarLookup){
if (daVarLookup.hasOwnProperty(rawFieldName)){
var fieldName = atob(rawFieldName);
if (allFields.indexOf(fieldName) == -1){
allFields.push(fieldName);
}
}
}
return allFields;
}
function getField(fieldName){
if (typeof daValLookup[fieldName] == "undefined"){
var fieldNameEscaped = btoa(fieldName).replace(/[\\n=]/g, '');//.replace(/(:|\.|\[|\]|,|=)/g, "\\\\$1");
Expand Down Expand Up @@ -17361,6 +17395,17 @@ def playground_packages():
the_pypi_package_name = None
if github_message is not None and github_url_from_file is not None and github_url_from_file != github_http and github_url_from_file != github_ssh:
github_message += ' ' + word("This package was originally pulled from") + ' <a target="_blank" href="' + github_as_http(github_url_from_file) + '">' + word('a GitHub repository') + '</a>.'
if github_message is not None and old_info.get('github_branch', None) and (github_http or github_url_from_file):
html_url = github_http or github_url_from_file
commit_code = None
current_commit_file = os.path.join(directory_for(area['playgroundpackages'], current_project), '.' + github_package_name)
if os.path.isfile(current_commit_file):
with open(current_commit_file, 'rU', encoding='utf-8') as fp:
commit_code = fp.read().strip()
if commit_code:
github_message += ' ' + word('The current branch is %s and the current commit is %s.') % ('<a target="_blank" href="' + html_url + '/tree/' + old_info['github_branch'] + '">' + old_info['github_branch'] + '</a>', '<a target="_blank" href="' + html_url + '/commit/' + commit_code + '"><code>' + commit_code[0:7] + '</code></a>')
else:
github_message += ' ' + word('The current branch is %s.') % ('<a target="_blank" href="' + html_url + '/tree/' + old_info['github_branch'] + '">' + old_info['github_branch'] + '</a>',)
if github_message is not None:
github_message = Markup(github_message)
branch = old_info.get('github_branch', None)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit d332929

Please sign in to comment.