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

Commit

Permalink
Merge pull request #122 from NoumbissiValere/issue/121
Browse files Browse the repository at this point in the history
Issue/121
  • Loading branch information
nemesifier committed Jun 17, 2019
2 parents a439eb8 + 85e571b commit c74cc02
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ matrix:
branches:
only:
- master
- gsoc2019

before_install:
- pip install -U pip wheel setuptools
Expand Down
2 changes: 1 addition & 1 deletion django_netjsonconfig/api/generics.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class BaseSearchTemplate(ListAPIView):
def get_queryset(self):
name = self.request.GET.get('name', None)
des = self.request.GET.get('des', None)
temp = self.template_model.filter(sharing='public')
temp = self.template_model.objects.filter(sharing='public')
if name and des is None:
temp = temp.filter(name__icontains=name)
elif des and name is None:
Expand Down
12 changes: 6 additions & 6 deletions django_netjsonconfig/static/django-netjsonconfig/js/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,18 @@
};

var evaluateVars = function(data, context){
var pattern = new RegExp('\{\{.*?\}\}');
var pattern = /^\{\{\s*(\w*)\s*\}\}$/g;
if (typeof data === 'object'){
for (var [key, value] of Object.entries(data)){
data[key] = evaluateVars(value, context);
}
Object.keys(data).forEach(function(key) {
data[key] = evaluateVars(data[key], context);
});
}
if (typeof data === 'string') {
var found_vars = data.match(pattern);
if (found_vars != null){
if (found_vars !== null){
found_vars.forEach(function(element) {
element = element.replace(/^\{\{\s+|\s+\}\}$|^\{\{|\}\}$/g, '');
if (element in context){
if (context.hasOwnProperty(element)){
data = data.replace(pattern, context[element]);
}
});
Expand Down

0 comments on commit c74cc02

Please sign in to comment.