Skip to content

Commit d332929

Browse files
committed
getFields; empty multiple choice and continue button field; font awesome; github branch and commit; ask_number DAObject error; sql ping fix
1 parent 2f77d49 commit d332929

39 files changed

+2646
-507
lines changed

CHANGELOG.md

+17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Change Log
22

3+
## [1.1.23] - 2020-05-03
4+
### Added
5+
- The `getFields()` JavaScript function.
6+
### Changed
7+
- A `question` with `fields` that contains a single multiple choice
8+
field where the choices are empty is not skipped if the `question`
9+
has a `continue button field`.
10+
- The branch and commit are shown in the Packages page of the
11+
Playground when GitHub integration is enabled and the package has a
12+
known presence on GitHub.
13+
- Upgraded Font Awesome to 5.13.0.
14+
### Fixed
15+
- Infinite loop when a list is gathered and `object_type` is set to a
16+
class for which the textual representation or `complete_element` is
17+
pre-defined and a set number of items are to be gathered.
18+
- The `sql ping` feature was not fully implemented.
19+
320
## [1.1.22] - 2020-04-30
421
### Changed
522
- When a item is added to or removed from a group, the `there_are_any`

CONTRIBUTING.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ you wish to make via issue, email, or any other method with the owner
55
of this repository before making a change. The best way to contribute
66
a change is through a pull request.
77

8+
If you want to add an additional feature, first consider if the
9+
feature could be made available through an [add-on
10+
package](https://docassemble.org/docs/packages.html). If the feature
11+
turns out to be universally useful, it can be incorporated later into
12+
the core code.
13+
14+
## How to modify and test the core docassemble code
15+
16+
For instructions on how to test modificiations to the core code, see the
17+
[workflow for making changes to the core docassemble code](https://docassemble.org/docs/development.html#core).
18+
819
## How to contribute to the documentation
920

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

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

docassemble_base/docassemble/base/core.py

+1
Original file line numberDiff line numberDiff line change
@@ -1536,6 +1536,7 @@ def gather(self, number=None, item_object_type=None, minimum=None, complete_attr
15361536
#str(self.__getitem__(the_length))
15371537
# if item_object_type is not None and complete_attribute is not None:
15381538
# getattr(self.__getitem__(the_length), complete_attribute)
1539+
the_length = len(self.elements)
15391540
if hasattr(self, '_necessary_length'):
15401541
del self._necessary_length
15411542
elif minimum != 0:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
metadata:
2+
title: List of fields
3+
documentation: "https://docassemble.org/docs/functions.html#js_getFields"
4+
---
5+
question: |
6+
Tell me about your musical tastes.
7+
fields:
8+
- Best band ever: best_band
9+
- Best singer ever: best_singer
10+
- Best composer ever: best_composer
11+
- Best songwriter ever: best_songwriter
12+
- html: |
13+
<a href="#" id="decide_for_me" class="btn btn-success">Decide for me</a>
14+
script: |
15+
<script>
16+
$("#decide_for_me").click(function(){
17+
var fields = getFields();
18+
for (var i = 0; i < fields.length; ++i){
19+
setField(fields[i], 'Carly Simon');
20+
}
21+
return false;
22+
});
23+
</script>
24+
---
25+
mandatory: True
26+
question: |
27+
You like ${ comma_and_list(set([best_band, best_singer, best_composer, best_songwriter])) }.

docassemble_base/docassemble/base/data/sources/base-words.yml

+2
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,8 @@
524524
"That screen is already being controlled by another operator": Null
525525
"The author is": Null
526526
"The configuration file was saved.": Null
527+
"The current branch is %s and the current commit is %s.": Null
528+
"The current branch is %s.": Null
527529
"The default project cannot be deleted.": Null
528530
"The document is available in the following formats:": Null
529531
"The file you requested does not exist.": Null

docassemble_base/docassemble/base/parse.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -4516,7 +4516,10 @@ def ask(self, user_dict, old_user_dict, the_x, iterators, sought, orig_sought, p
45164516
for indexno in range(len(iterators)):
45174517
exec(list_of_indices[indexno] + " = " + iterators[indexno], user_dict)
45184518
else:
4519-
only_empty_fields_exist = True
4519+
if hasattr(self, 'fields_saveas'):
4520+
only_empty_fields_exist = False
4521+
else:
4522+
only_empty_fields_exist = True
45204523
commands_to_run = list()
45214524
for field in self.fields:
45224525
if hasattr(field, 'inputtype') and field.inputtype == 'combobox':
@@ -7838,7 +7841,7 @@ def _fail_with_undefined_error(self, *args, **kwargs):
78387841
self._undefined_name
78397842
)
78407843
else:
7841-
hint = '%r has got no attribute %r' % (
7844+
hint = '%r has no attribute %r' % (
78427845
object_type_repr(self._undefined_obj),
78437846
self._undefined_name
78447847
)

docassemble_webapp/docassemble/webapp/db_object.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@
44
def init_flask():
55
global db
66
global UserMixin
7-
from flask_sqlalchemy import SQLAlchemy
7+
import docassemble.webapp.database
8+
if docassemble.webapp.database.pool_pre_ping:
9+
from flask_sqlalchemy import SQLAlchemy as _BaseSQLAlchemy
10+
class SQLAlchemy(_BaseSQLAlchemy):
11+
def apply_pool_defaults(self, app, options):
12+
super().apply_pool_defaults(app, options)
13+
options["pool_pre_ping"] = True
14+
else:
15+
from flask_sqlalchemy import SQLAlchemy
816
db = SQLAlchemy()
917
import flask_user
1018
UserMixin = flask_user.UserMixin

docassemble_webapp/docassemble/webapp/server.py

+47-2
Original file line numberDiff line numberDiff line change
@@ -3213,7 +3213,7 @@ def get_vars_in_use(interview, interview_status, debug_mode=False, return_json=F
32133213
if base_name_info[var]['show']:
32143214
names_used.add(var)
32153215
names_used = set([i for i in names_used if not extraneous_var.search(i)])
3216-
for var in ('_internal', '__object_type'):
3216+
for var in ('_internal', '__object_type', '_DAOBJECTDEFAULTDA'):
32173217
names_used.discard(var)
32183218
for var in interview.mlfields:
32193219
names_used.discard(var + '.text')
@@ -3271,7 +3271,7 @@ def get_vars_in_use(interview, interview_status, debug_mode=False, return_json=F
32713271
while '.' in the_var:
32723272
the_var = re.sub(r'(.*)\..*$', r'\1', the_var)
32733273
implicitly_defined.add(the_var)
3274-
for var in ('_internal', '__object_type'):
3274+
for var in ('_internal', '__object_type', '_DAOBJECTDEFAULTDA'):
32753275
undefined_names.discard(var)
32763276
vocab_set.discard(var)
32773277
for var in [x for x in undefined_names if x.endswith(']')]:
@@ -7330,6 +7330,23 @@ def index(action_argument=None):
73307330
else{
73317331
daTargetDiv = "#dabody";
73327332
}
7333+
function getFields(){
7334+
var allFields = [];
7335+
for (var fieldName in daValLookup){
7336+
if (daValLookup.hasOwnProperty(fieldName)){
7337+
allFields.push(fieldName);
7338+
}
7339+
}
7340+
for (var rawFieldName in daVarLookup){
7341+
if (daVarLookup.hasOwnProperty(rawFieldName)){
7342+
var fieldName = atob(rawFieldName);
7343+
if (allFields.indexOf(fieldName) == -1){
7344+
allFields.push(fieldName);
7345+
}
7346+
}
7347+
}
7348+
return allFields;
7349+
}
73337350
function getField(fieldName){
73347351
if (typeof daValLookup[fieldName] == "undefined"){
73357352
var fieldNameEscaped = btoa(fieldName).replace(/[\\n=]/g, '');//.replace(/(:|\.|\[|\]|,|=)/g, "\\\\$1");
@@ -11227,6 +11244,23 @@ def observer():
1122711244
}
1122811245
}
1122911246
}
11247+
function getFields(){
11248+
var allFields = [];
11249+
for (var fieldName in daValLookup){
11250+
if (daValLookup.hasOwnProperty(fieldName)){
11251+
allFields.push(fieldName);
11252+
}
11253+
}
11254+
for (var rawFieldName in daVarLookup){
11255+
if (daVarLookup.hasOwnProperty(rawFieldName)){
11256+
var fieldName = atob(rawFieldName);
11257+
if (allFields.indexOf(fieldName) == -1){
11258+
allFields.push(fieldName);
11259+
}
11260+
}
11261+
}
11262+
return allFields;
11263+
}
1123011264
function getField(fieldName){
1123111265
if (typeof daValLookup[fieldName] == "undefined"){
1123211266
var fieldNameEscaped = btoa(fieldName).replace(/[\\n=]/g, '');//.replace(/(:|\.|\[|\]|,|=)/g, "\\\\$1");
@@ -17361,6 +17395,17 @@ def playground_packages():
1736117395
the_pypi_package_name = None
1736217396
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:
1736317397
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>.'
17398+
if github_message is not None and old_info.get('github_branch', None) and (github_http or github_url_from_file):
17399+
html_url = github_http or github_url_from_file
17400+
commit_code = None
17401+
current_commit_file = os.path.join(directory_for(area['playgroundpackages'], current_project), '.' + github_package_name)
17402+
if os.path.isfile(current_commit_file):
17403+
with open(current_commit_file, 'rU', encoding='utf-8') as fp:
17404+
commit_code = fp.read().strip()
17405+
if commit_code:
17406+
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>')
17407+
else:
17408+
github_message += ' ' + word('The current branch is %s.') % ('<a target="_blank" href="' + html_url + '/tree/' + old_info['github_branch'] + '">' + old_info['github_branch'] + '</a>',)
1736417409
if github_message is not None:
1736517410
github_message = Markup(github_message)
1736617411
branch = old_info.get('github_branch', None)
Loading

0 commit comments

Comments
 (0)