Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python3 and Django2.2 upgrade] part 1 - Use Python 3 & Django 1.11 #678

Merged
merged 86 commits into from
Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from 85 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
2816633
Replaced basestring with six.string_types
noliveleger Apr 16, 2020
478350e
Replaced "assertEquals" with "assertEqual"
noliveleger Apr 16, 2020
e2b5a38
Replaced "unicode()" and "__unicode__" with six utilities
noliveleger Apr 16, 2020
12d90da
WIP - 2to3 fixes
noliveleger Apr 17, 2020
d33578f
Merge branch 'kobokitten-unicode' into kobokitten-py3
noliveleger Apr 21, 2020
e2e235b
Replaced "iteritems" with "items"
noliveleger Apr 21, 2020
865af36
Use "bytes" with hashlib
noliveleger Apr 21, 2020
26d87dd
Updated code for "filter", "itervalues()", "dict_keys()" and "dict_v…
noliveleger Apr 21, 2020
74ffb29
Replaced "urllib2" with "urllib"
noliveleger Apr 21, 2020
ee50a5e
Replaced "obj.next()" with "next(obj)"
noliveleger Apr 21, 2020
211932b
Django 1.11 support changes:
noliveleger Apr 22, 2020
6a8e0a3
Add dummy Django KEY for pytest
noliveleger Apr 22, 2020
ab28fa1
Fixed version of jsonfield
noliveleger Apr 22, 2020
b622428
Fixed compatibility issues for Python3, Django 1.11 and DRF 3.9
noliveleger Apr 22, 2020
465bf7a
Django 1.11 support: changed deprecated code for urls
noliveleger Apr 23, 2020
a38dd6e
Force AnonymousUser() FK to be settings.ANONYMOUS_USER_ID when runnin…
noliveleger Apr 23, 2020
6c48c28
Removed deprecated TEMPLATE_DIRS
noliveleger Apr 23, 2020
1fc5a2b
Make first test run: open files with "rb" mode, fixed bytes and str u…
noliveleger Apr 23, 2020
51bef8b
Removed `export` app
noliveleger Apr 24, 2020
3fd53bc
Open files in bytes mode
noliveleger Apr 24, 2020
dc05c80
Replaced reversed dotted path urls with their name - part 1
noliveleger Apr 24, 2020
6f94903
Fixed dotted path urls in templates
noliveleger Apr 27, 2020
7d78ccb
Fixed bad copy/paste from old version of openpyxl
noliveleger Apr 27, 2020
94ab153
Changed r/w mode of several "open()" calls
noliveleger Apr 27, 2020
814fd6f
Fixed pandas exports tests
noliveleger Apr 29, 2020
aab1942
Fixed exports tests
noliveleger Apr 29, 2020
d412cb4
Field API unit tests
noliveleger Apr 30, 2020
acb8791
Restore warning by default when running pytest
noliveleger May 8, 2020
b074fb2
Get rid of codec.open() in briefcase tests
noliveleger May 12, 2020
adfde79
Merge branch 'kobokitten-unicode' into kobokitten-py3
noliveleger May 12, 2020
4191ff5
Merge branch 'kobokitten-unicode' into kobokitten-py3
noliveleger Jun 19, 2020
b626a4e
Changed PASSWORD_HASHERS to list
noliveleger Jun 19, 2020
e463ba2
Use type <int> instead of string 'int' in management commands in argu…
noliveleger Jun 19, 2020
eee6540
Removed last occurences of codecs.open()
noliveleger Jun 19, 2020
854cc8c
Fixed some unittests - Open files in bytes mode
noliveleger Jun 19, 2020
c7ef98b
Added required options in publish_xls management command
noliveleger Jun 19, 2020
2d802aa
Removed useless assertion with Python3, reordered fixtures for Python…
noliveleger Jun 19, 2020
8e1a530
Create zip backup in bytes mode
noliveleger Jun 19, 2020
fa39913
Yet another commit for bytes vs str (Python2 unicode)
noliveleger Jun 29, 2020
1847b5e
Removed reference to form statistics in HTML templates
noliveleger Jun 29, 2020
a337288
Use MIDDLEWARE instead of MIDDLEWARE_CLASSES
noliveleger Jun 29, 2020
72e24da
Fixed form permissions tests
noliveleger Jun 29, 2020
c8a2325
Fixed form exports tests
noliveleger Jun 29, 2020
8843c26
Fixed form api tests
noliveleger Jun 30, 2020
06700a2
Test fix: Use binary mode with open()
noliveleger Jun 30, 2020
31ae041
Removed deprecated TEMPLATES_DIR, TEMPLATE_CONTEXT_PROCESSORS
noliveleger Jun 30, 2020
025efda
PEP-8 adjustements
noliveleger Jun 30, 2020
b763ac0
Removed deprecated "context_instance" parameter
noliveleger Jul 2, 2020
f5a05a9
Removed dotted urls in reverse() calls
noliveleger Jul 14, 2020
507e3d9
Other bytes/unicode fixes
noliveleger Jul 14, 2020
770a59b
Misc fixes
noliveleger Jul 14, 2020
8c40578
Fixed GoogleDoc and remaining BriefCase tests
noliveleger Jul 14, 2020
26442ab
Fixed SMS tests
noliveleger Jul 14, 2020
f0a72a9
Fixed zip exports tests
noliveleger Jul 14, 2020
6619487
Fixed sav_zip export test
noliveleger Jul 14, 2020
423a62d
Fixed last batch of tests, BytesIO vs StringIO, open in binary mode e…
noliveleger Jul 15, 2020
55713ab
Call to deprecated function get_sheet_by_name (Use wb[sheetname]).
noliveleger Jul 15, 2020
809b7b8
PyMongo count is deprecated. Use Collection.count_documents instead
noliveleger Jul 15, 2020
213d13a
Added "on_delete=models.CASCADE" on foreign key
noliveleger Jul 15, 2020
d587095
Removed Ziggy fixtures
noliveleger Jul 15, 2020
d4e401d
Added missing "on_delete=models.CASCADE"
noliveleger Jul 16, 2020
ed8c488
Removed ziggy fixtures
noliveleger Jul 16, 2020
dc5b36a
Use set() for User permissions assignments
noliveleger Jul 16, 2020
7f0315e
Replaced deprecated PyMongo method calls
noliveleger Jul 16, 2020
a67dff6
Deprecated: openpyxl "wb.get_sheet_names()" - Replaced with "wb.sheet…
noliveleger Jul 16, 2020
8382796
Deprecated assertNotEquals
noliveleger Jul 16, 2020
3edcc3c
fixed: PyMongo delete_many does not take "j" argument
noliveleger Jul 16, 2020
f634beb
deprecated: removed GeoManager
noliveleger Jul 16, 2020
fa00c2a
fixed: admin.site.urls
noliveleger Jul 16, 2020
0b8f58e
Removed python_2_unicode_compatible decorator
noliveleger Jul 16, 2020
3b8e771
Added new migration to clean not-used models
noliveleger Jul 20, 2020
9180b66
Merge branch 'kobokitten-unicode' into kobokitten-py3
noliveleger Jul 23, 2020
c1b0cfe
Update wront port script to Python3
noliveleger Jul 24, 2020
9902992
Merge branch 'kobokitten-unicode' into kobokitten-py3
noliveleger Jul 28, 2020
4b94743
fixed: User connection with Digest
noliveleger Jul 28, 2020
da6247b
Removed path.py dependency for xlsx exports
noliveleger Jul 28, 2020
1a51872
deprecated: replaced user.anonymous() with user.anonymous
noliveleger Jul 28, 2020
d2b7261
Merge branch 'kobokitten-remove-ui-CUD-actions-unicode' into kobokitt…
noliveleger Aug 19, 2020
d553e1c
Removed zombie files forgotten after merge
noliveleger Aug 20, 2020
f7e4f1e
Merge branch 'kobokitten-remove-ui-CUD-actions-unicode' into kobokitt…
noliveleger Aug 20, 2020
301920c
Merge branch 'kobokitten-remove-ui-CUD-actions-unicode' into kobokitt…
noliveleger Dec 17, 2020
00deb30
Merge branch 'kobokitten-remove-ui-CUD-actions-unicode' into kobokitt…
noliveleger Dec 17, 2020
7b66047
Fixed upgrade issues
noliveleger Dec 17, 2020
014c0fd
Merge branch 'kobokitten-remove-ui-CUD-actions-unicode' into kobokitt…
noliveleger Mar 4, 2021
b190d0b
Merge branch 'kobocat2.0-step0-remove-deprecated-views' into kobocat2…
noliveleger Mar 4, 2021
0f1dba9
Merge branch 'kobocat2.0-step0-remove-deprecated-views' into kobocat2…
noliveleger Mar 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,10 @@
'peter',
]

try:
INTERRUPTED = pytest.ExitCode.INTERRUPTED # pytest 5
except AttributeError:
INTERRUPTED = 2


def stderr_prompt(message):
sys.stderr.write(message)
# FIXME: Python 3 compatibility
return raw_input().strip()
return input().strip()


def toggle_capturing(capture_manager, stop):
Expand Down Expand Up @@ -63,7 +57,7 @@ def setup(request):
if response.lower() != 'yes':
if is_global_capturing:
toggle_capturing(capture_manager, stop=False)
pytest.exit('User interrupted tests', INTERRUPTED)
pytest.exit('User interrupted tests', pytest.ExitCode.INTERRUPTED)

if 'instances' in settings.MONGO_DB.collection_names():
response = stderr_prompt(
Expand All @@ -77,7 +71,7 @@ def setup(request):
else:
if is_global_capturing:
toggle_capturing(capture_manager, stop=False)
pytest.exit('User interrupted tests', INTERRUPTED)
pytest.exit('User interrupted tests', pytest.ExitCode.INTERRUPTED)

if is_global_capturing:
toggle_capturing(capture_manager, stop=False)
Expand Down
16 changes: 9 additions & 7 deletions docker/dev_wrong_port_warning.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@
provides a helpful message to anyone still trying to use port 8000
"""

import BaseHTTPServer
import sys
from http.server import BaseHTTPRequestHandler, HTTPServer

class Handler(BaseHTTPServer.BaseHTTPRequestHandler):

class Handler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(503)
self.end_headers()
self.wfile.write(
'Your development environment is trying to connect to the KoBoCAT '
'container on port 8000 instead of 8001. Please change this. See '
'https://github.com/kobotoolbox/kobo-docker/issues/301 '
'for more details.'
b'Your development environment is trying to connect to the KoBoCAT '
b'container on port 8000 instead of 8001. Please change this. See '
b'https://github.com/kobotoolbox/kobo-docker/issues/301 '
b'for more details.'
)


server_address = ('', int(sys.argv[1]))
httpd = BaseHTTPServer.HTTPServer(server_address, Handler)
httpd = HTTPServer(server_address, Handler)
httpd.serve_forever()
2 changes: 1 addition & 1 deletion kobocat-template/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
{% block javascript %}

<!-- Le javascript -->
<script type="text/javascript" src="{% url "django.views.i18n.javascript_catalog" %}"></script>
<script type="text/javascript" src="{% url "javascript-catalog" %}"></script>
<script src="{% static "js/jquery.min.js" %}"></script>
<script src="{% static "js/jquery-migrate.min.js" %}"></script>
<script src="{% static "js/jquery.tablesorter.min.js" %}"></script>
Expand Down
12 changes: 6 additions & 6 deletions kobocat-template/templates/export_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<div class="sub-header-bar">
<div class="container__wide">
<a class="sub-header__back" href="{% url "onadata.apps.main.views.show" xform.user.username xform.id_string %}"><i class="fa fa-chevron-left"></i> {% trans "Return to" %} {{ xform.title }}</a>
<a class="sub-header__back" href="{% url "show_form" xform.user.username xform.id_string %}"><i class="fa fa-chevron-left"></i> {% trans "Return to" %} {{ xform.title }}</a>
</div>
</div>

Expand All @@ -25,7 +25,7 @@ <h1>{{ export_type_name|upper }} {% blocktrans %}Exports{% endblocktrans %}</h1>
<section id="export-downloads">

{% if user.is_authenticated %}
<form action="{% url "onadata.apps.viewer.views.create_export" username xform.id_string export_type %}" method="post" enctype="application/x-www-form-urlencoded">
<form action="{% url "create_export" username xform.id_string export_type %}" method="post" enctype="application/x-www-form-urlencoded">
{% csrf_token %}
<span style='float:middle;'>
<div>
Expand All @@ -40,7 +40,7 @@ <h1>{{ export_type_name|upper }} {% blocktrans %}Exports{% endblocktrans %}</h1>
{% endif %}

<div id="advanced-export-modal" class="modal hide fade">
<form action="{% url "onadata.apps.viewer.views.create_export" username xform.id_string export_type %}" method="post" enctype="application/x-www-form-urlencoded">
<form action="{% url "create_export" username xform.id_string export_type %}" method="post" enctype="application/x-www-form-urlencoded">
{% csrf_token %}
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
Expand Down Expand Up @@ -80,7 +80,7 @@ <h3>{% trans "Advanced Export" %}</h3>
<td>
{% if not export.is_pending %}
{% if export.is_successful %}
<a href="{% url "onadata.apps.viewer.views.export_download" username xform.id_string export.export_type export.filename %}">{{ export.filename }}</a>
<a href="{% url "export_download" username xform.id_string export.export_type export.filename %}">{{ export.filename }}</a>
{% else %}
Failed
{% endif %}
Expand All @@ -91,7 +91,7 @@ <h3>{% trans "Advanced Export" %}</h3>
</td>
<td>{{ export.created_on }}</td>
<td>
<form action="{% url "onadata.apps.viewer.views.delete_export" username xform.id_string export_type %}" method="post" enctype="application/x-www-form-urlencoded">
<form action="{% url "delete_export" username xform.id_string export_type %}" method="post" enctype="application/x-www-form-urlencoded">
{% csrf_token %}
<div id="delete-{{ export.id|stringformat:"d" }}" class="modal hide fade">
<div class="modal-header">
Expand Down Expand Up @@ -132,6 +132,6 @@ <h3>{% trans "Delete Export" %}</h3>
<script type="text/javascript" charset="utf-8" src="{% static "js/underscore-min.js" %}"></script>
<script type="text/javascript" charset="utf-8" src="{% static "js/export_list.js" %}"></script>
<script type="text/javascript">
var progress_url = '{% url "onadata.apps.viewer.views.export_progress" username xform.id_string export_type %}';
var progress_url = '{% url "export_progress" username xform.id_string export_type %}';
</script>
{% endblock %}
4 changes: 2 additions & 2 deletions kobocat-template/templates/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<body>
{% include "topbar.html" %}
<div class="map__back"><a href="{% url "onadata.apps.main.views.show" xform.user.username xform.id_string %}">back
<div class="map__back"><a href="{% url "show" xform.user.username xform.id_string %}">back
to project</a></div>

<ul class="nav pull-right map__viewby">
Expand Down Expand Up @@ -75,7 +75,7 @@
var mongoAPIUrl = "{{ mongo_api_url }}";
var deleteAPIUrl = "{{ delete_data_url }}";
var language_code = "{{LANGUAGE_CODE}}";
var attachmentsBaseUrl = "{% url "onadata.apps.viewer.views.attachment_url" %}";
var attachmentsBaseUrl = "{% url "attachment_url" %}";
var userName = "{{ content_user }}";
var modalVisible = null;
var idToDelete = null;
Expand Down
4 changes: 2 additions & 2 deletions kobocat-template/templates/published_forms__list.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<tr class="published_forms__form">
<td></td>
<td class="published_forms__cell published_forms__cell--project">
<a href="{% url "onadata.apps.main.views.show" xform.user.username xform.id_string %}">{{ xform.title }}</a>
<a href="{% url "show_form" xform.user.username xform.id_string %}">{{ xform.title }}</a>
{% if xform.description %}
<div class="project__description">
{{ xform.description }}
Expand Down Expand Up @@ -58,4 +58,4 @@


</tbody>
</table>
</table>
18 changes: 7 additions & 11 deletions kobocat-template/templates/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,10 @@ <h2 class="dashboard__group-label">
</a>

<div class="dashboard__download__drop hidden">
<a href="{% url "onadata.apps.viewer.views.export_list" content_user.username xform.id_string 'xls' %}"
class="download__drop-button">XLS</a>
<a href="{% url "onadata.apps.viewer.views.export_list" content_user.username xform.id_string 'csv' %}"
class="download__drop-button">CSV</a>
<a href="{% url "onadata.apps.viewer.views.export_list" content_user.username xform.id_string 'zip' %}"
class="download__drop-button">ZIP</a>
<a href="{% url "onadata.apps.viewer.views.export_list" content_user.username xform.id_string 'kml' %}"
class="download__drop-button">KML</a>
<a href="{% url "export_list" content_user.username xform.id_string 'xls' %}" class="download__drop-button">XLS</a>
<a href="{% url "export_list" content_user.username xform.id_string 'csv' %}" class="download__drop-button">CSV</a>
<a href="{% url "export_list" content_user.username xform.id_string 'zip' %}" class="download__drop-button">ZIP</a>
<a href="{% url "export_list" content_user.username xform.id_string 'kml'%}" class="download__drop-button">KML</a>
</div>
</div>

Expand All @@ -49,12 +45,12 @@ <h2 class="dashboard__group-label">
</h2>

<a title="{% trans "View Photos" %}"
href="{% url "onadata.apps.main.views.form_photos" content_user.username xform.id_string %}"
href="{% url "form_photos" content_user.username xform.id_string %}"
class="dashboard__button dashboard__button-view-gallery">
<i class="fa fa-eye"></i>
<span>View gallery</span>
</a>
<a href="{% url "onadata.apps.viewer.views.export_list" content_user.username xform.id_string 'zip' %}"
<a href="{% url "export_list" content_user.username xform.id_string 'zip' %}"
class="dashboard__button dashboard__button-twoline dashboard__button-download-all-photos">
<i class="fa fa-download"></i>
<span>Download all photos</span>
Expand All @@ -77,7 +73,7 @@ <h2 class="dashboard__group-label">
{% if xform.has_instances_with_geopoints %}
<div class="dashboard__gps">
<h2 class="dashboard__group-label">GPS Points</h2>
<a href="{% url "onadata.apps.viewer.views.export_list" content_user.username xform.id_string 'kml' %}"
<a href="{% url "export_list" content_user.username xform.id_string 'kml' %}"
class="dashboard__button dashboard__button-twoline dashboard__button-download-gps-points">
<i class="fa fa-download"></i>
<span>Download GPS points</span>
Expand Down
6 changes: 3 additions & 3 deletions kobocat-template/templates/show_form_settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ <h2 class="settings__group-label">
{% for media in media_upload %}
<li class="{% cycle 'odd' 'even' %}">
<div>{{ media.data_value }}</div>
<a href="{% url "onadata.apps.main.views.download_media_data" content_user.username xform.id_string media.id %}" class="settings__files-download" {% trans "download" %}><i class="fa fa-download"></i></a>
<a href="{% url "download_media_data" content_user.username xform.id_string media.id %}" class="settings__files-download" {% trans "download" %}><i class="fa fa-download"></i></a>
{% if can_edit %}
<a href="{% url "onadata.apps.main.views.download_media_data" content_user.username xform.id_string media.id %}?del=true" class="settings__files-delete" title="{% trans "remove" %}"><i class="fa fa-trash-o"></i></a>
<a href="{% url "download_media_data" content_user.username xform.id_string media.id %}?del=true" class="settings__files-delete" title="{% trans "remove" %}"><i class="fa fa-trash-o"></i></a>
{% endif %}
</li>
{% endfor %}
Expand All @@ -38,7 +38,7 @@ <h2 class="settings__group-label">
{% if can_edit %}
<button class="single-project__button single-project__add-media">+ Add Document</button>

<form action="{% url "onadata.apps.main.views.edit" content_user.username xform.id_string %}" method="post" enctype="multipart/form-data" class="single-project__media-upload hidden">
<form action="{% url "edit_form" content_user.username xform.id_string %}" method="post" enctype="multipart/form-data" class="single-project__media-upload hidden">
{% csrf_token %}
<ul class="nav nav-tabs">
<li class="active"><a href="#media_upload" data-toggle="tab">Media Upload</a></li>
Expand Down
20 changes: 10 additions & 10 deletions onadata/apps/api/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='OrganizationProfile',
fields=[
('userprofile_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='main.UserProfile')),
('userprofile_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='main.UserProfile', on_delete=models.CASCADE)),
('is_organization', models.BooleanField(default=True)),
('creator', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
('creator', models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
],
options={
'permissions': (('can_add_xform', 'Can add/upload an xform to organization'), ('view_organizationprofile', 'Can view organization profile')),
Expand All @@ -39,8 +39,8 @@ class Migration(migrations.Migration):
('shared', models.BooleanField(default=False)),
('date_created', models.DateTimeField(auto_now_add=True)),
('date_modified', models.DateTimeField(auto_now=True)),
('created_by', models.ForeignKey(related_name='project_creator', to=settings.AUTH_USER_MODEL)),
('organization', models.ForeignKey(related_name='project_organization', to=settings.AUTH_USER_MODEL)),
('created_by', models.ForeignKey(related_name='project_creator', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
('organization', models.ForeignKey(related_name='project_organization', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
('tags', taggit.managers.TaggableManager(to='taggit.Tag', through='taggit.TaggedItem', help_text='A comma-separated list of tags.', verbose_name='Tags')),
('user_stars', models.ManyToManyField(to=settings.AUTH_USER_MODEL)),
],
Expand All @@ -52,19 +52,19 @@ class Migration(migrations.Migration):
name='ProjectXForm',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('created_by', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
('project', models.ForeignKey(to='api.Project')),
('xform', models.ForeignKey(to='logger.XForm')),
('created_by', models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
('project', models.ForeignKey(to='api.Project', on_delete=models.CASCADE)),
('xform', models.ForeignKey(to='logger.XForm', on_delete=models.CASCADE)),
],
),
migrations.CreateModel(
name='Team',
fields=[
('group_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='auth.Group')),
('group_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='auth.Group', on_delete=models.CASCADE)),
('date_created', models.DateTimeField(auto_now_add=True, null=True)),
('date_modified', models.DateTimeField(auto_now=True, null=True)),
('created_by', models.ForeignKey(related_name='team_creator', blank=True, to=settings.AUTH_USER_MODEL, null=True)),
('organization', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
('created_by', models.ForeignKey(related_name='team_creator', blank=True, to=settings.AUTH_USER_MODEL, null=True, on_delete=models.CASCADE)),
('organization', models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
('projects', models.ManyToManyField(to='api.Project')),
],
options={
Expand Down
11 changes: 6 additions & 5 deletions onadata/apps/api/mongo_helper.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
from __future__ import unicode_literals, print_function, division, absolute_import
import re
import base64


from onadata.libs.utils.common_tags import NESTED_RESERVED_ATTRIBUTES
from onadata.libs.utils.string import base64_encodestring


class MongoHelper(object):

KEY_WHITELIST = ['$or', '$and', '$exists', '$in', '$gt', '$gte',
'$lt', '$lte', '$regex', '$options', '$all']
ENCODING_SUBSTITUTIONS = [
(re.compile(r'^\$'), base64.encodestring('$').strip()),
(re.compile(r'\.'), base64.encodestring('.').strip()),
(re.compile(r'^\$'), base64_encodestring('$').strip()),
(re.compile(r'\.'), base64_encodestring('.').strip()),
]
DECODING_SUBSTITUTIONS = [
(re.compile(r'^' + base64.encodestring('$').strip()), '$'),
(re.compile(base64.encodestring('.').strip()), '.'),
(re.compile(r'^' + base64_encodestring('$').strip()), '$'),
(re.compile(base64_encodestring('.').strip()), '.'),
]

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion onadata/apps/api/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def has_permission(self, request, view):
perms = self.get_required_permissions(request.method, model_cls)

if (request.user and
(request.user.is_authenticated() or
(request.user.is_authenticated or
not self.authenticated_users_only) and
request.user.has_perms(perms)):

Expand Down
23 changes: 0 additions & 23 deletions onadata/apps/api/tests/fixtures/movie_form_submission.json

This file was deleted.

Loading