diff --git a/app/server/static/js/projects.js b/app/server/static/js/projects.js index ff1d1e01..06bfaccb 100644 --- a/app/server/static/js/projects.js +++ b/app/server/static/js/projects.js @@ -6,12 +6,5 @@ new Vue({ components: { Projects }, - data: { - djangoContext: { - username: JSON.parse(document.getElementById('django.username').textContent), - isSuperuser: JSON.parse(document.getElementById('django.is_superuser').textContent), - }, - }, - - template: '', + template: '', }); diff --git a/app/server/static/js/projects.vue b/app/server/static/js/projects.vue index 311b6a32..7ad79e89 100644 --- a/app/server/static/js/projects.vue +++ b/app/server/static/js/projects.vue @@ -204,17 +204,6 @@ const baseUrl = window.location.href.split('/').slice(0, 3).join('/'); export default { filters: { title, daysAgo }, - props: { - username: { - type: String, - required: true, - }, - isSuperuser: { - type: Boolean, - default: false, - }, - }, - data: () => ({ items: [], isActive: false, @@ -227,6 +216,8 @@ export default { descriptionError: '', projectTypeError: '', projectNameError: '', + username: '', + isSuperuser: false, }), computed: { @@ -236,8 +227,13 @@ export default { }, created() { - axios.get(`${baseUrl}/v1/projects`).then((response) => { - this.items = response.data; + Promise.all([ + axios.get(`${baseUrl}/v1/projects`), + axios.get(`${baseUrl}/v1/me`), + ]).then(([projects, me]) => { + this.items = projects.data; + this.username = me.data.username; + this.isSuperuser = me.data.is_superuser; }); }, diff --git a/app/server/templates/projects.html b/app/server/templates/projects.html index 9e998e8f..432d1b22 100644 --- a/app/server/templates/projects.html +++ b/app/server/templates/projects.html @@ -6,7 +6,5 @@
{% endblock %} {% block footer %} -{{ user.get_username | json_script:"django.username" }} -{{ user.is_superuser | json_script:"django.is_superuser" }} {% render_bundle 'projects' 'js' %} {% endblock %}