Skip to content

Commit

Permalink
Merge pull request #23 from rafaelpezzuto/reorganize-all
Browse files Browse the repository at this point in the history
Reorganiza código-fonte para melhorar legibilidade
  • Loading branch information
rafaelpezzuto authored Oct 6, 2021
2 parents e039ccc + 60aa1c1 commit 184dc5f
Show file tree
Hide file tree
Showing 19 changed files with 196 additions and 164 deletions.
4 changes: 2 additions & 2 deletions spf/core/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


def _is_privileged_user(user):
return GROUP_MANAGER in get_groups_names_from_user(user) or user.is_superuser() or user.is_staff()
return GROUP_MANAGER in get_groups_names_from_user(user) or user.is_superuser or user.is_staff


def _get_objects_from_user_and_scope(user, scope, model_class):
Expand All @@ -14,7 +14,7 @@ def _get_objects_from_user_and_scope(user, scope, model_class):
return model_class.objects.filter(user=user)


def get_deposited_packages_from_user_and_scope(user, scope):
def get_ingress_packages_from_user_and_scope(user, scope):
return _get_objects_from_user_and_scope(user, scope, IngressPackage)


Expand Down
4 changes: 2 additions & 2 deletions spf/core/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function createMessage(msg){
return divAlert;
}

function userPackageDownloadToggleSpinner(){
function ingressPackageDownloadToggleSpinner(){
var btnSearchPackage = document.getElementById('btnSearchPackage');
var divSpinner = document.getElementById('searchPackageLoading');
if (divSpinner.style.display == "none") {
Expand All @@ -31,7 +31,7 @@ function userPackageDownloadToggleSpinner(){
}
}

function userPackageDownloadCreateTable(data){
function ingressPackageDownloadCreateTable(data){
tableBody = document.getElementById('resultSearchPackagesTableBody')

for (k in data['doc_pkg']){
Expand Down
2 changes: 1 addition & 1 deletion spf/core/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<li><a class="dropdown-item" href="{% url 'event_list' %}"><i class="fas fa-columns px-2"></i>{% trans "Events" %}</a></li>
<li><a class="dropdown-item" href="{% url 'user_profile' %}"><i class="fas fa-columns px-2"></i>{% trans "Profile" %}</a></li>
<li><a class="dropdown-item" href="{% url 'user_profile_edit' %}"><i class="fas fa-cog px-2"></i>{% trans "Edit profile" %}</a></li>
<li><a class="dropdown-item" href="{% url 'change_password' %}"><i class="fas fa-cog px-2"></i>{% trans "Change password" %}</a></li>
<li><a class="dropdown-item" href="{% url 'user_change_password' %}"><i class="fas fa-cog px-2"></i>{% trans "Change password" %}</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="{% url 'logout' %}"><i class="fas fa-sign-out-alt px-2"></i>{% trans "Logout" %}</a></li>
</ul>
Expand Down
12 changes: 6 additions & 6 deletions spf/core/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ <h1 class="h4 pt-5">{% trans 'Home' %}</h1>
<div class="list-group list-group-flush">
<a class="list-group-item" href="{% url 'event_list' %}">{% trans 'Events' %}</a>
{% if user.is_superuser or user|has_group:"manager" or user|has_group:"operator_ingress" %}
<a class="list-group-item" href="{% url 'package_list' %}">{% trans "Deposited packages" %}</a>
<a class="list-group-item" href="{% url 'ingress_package_list' %}">{% trans "Deposited packages" %}</a>
{% endif %}
{% if user.is_superuser or user|has_group:"manager" or user|has_group:"operator_migration" %}
<a class="list-group-item disabled" href="">{% trans "Migrated data" %}</a>
{% endif %}
<a class="list-group-item" href="{% url 'user_profile' %}">{% trans 'Profile' %}</a>
<a class="list-group-item list-group-item-warning" href="{% url 'user_profile_edit' %}">{% trans 'Edit profile' %}</a>
<a class="list-group-item list-group-item-warning" href="{% url 'change_password' %}">{% trans 'Change password' %}</a>
<a class="list-group-item list-group-item-warning" href="{% url 'user_change_password' %}">{% trans 'Change password' %}</a>
</div>
</div>
</div>
Expand All @@ -37,8 +37,8 @@ <h1 class="h4 pt-5">{% trans 'Home' %}</h1>
{% trans 'Ingress' %}
</div>
<div class="list-group list-group-flush">
<a class="list-group-item" href="{% url 'user_package_download' %}">{% trans 'Search package' %}</a>
<a class="list-group-item" href="{% url 'user_package_upload' %}">{% trans 'Upload package' %}</a>
<a class="list-group-item" href="{% url 'ingress_package_download' %}">{% trans 'Search package' %}</a>
<a class="list-group-item" href="{% url 'ingress_package_upload' %}">{% trans 'Upload package' %}</a>
</div>
</div>
</div>
Expand Down Expand Up @@ -83,8 +83,8 @@ <h1 class="h4 pt-5">{% trans 'Home' %}</h1>
{% trans 'Package management' %}
</div>
<div class="list-group list-group-flush">
<a class="list-group-item" href="{% url 'package_list' %}?scope=all_users">{% trans 'All deposited packages' %}</a>
<a class="list-group-item" href="{% url 'article_files_list' %}">{% trans "Articles' files" %}</a>
<a class="list-group-item" href="{% url 'ingress_package_list' %}?scope=all_users">{% trans 'All deposited packages' %}</a>
<a class="list-group-item" href="{% url 'ingress_article_files_list' %}">{% trans "Articles' files" %}</a>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ <h1 class="h4 pt-5">{% trans "Articles' files" %}</h1>
</nav>
{% endif %}

{% endblock %}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h1 class="h4 pt-5">{% trans 'Search package' %}</h1>
{% trans 'Search package' %}
</div>
<div class="card-body">
<form class="bg-white form-user" method="GET" action="{% url 'user_package_download' %}">
<form class="bg-white form-user" method="GET" action="{% url 'ingress_package_download' %}">
{% csrf_token %}
<div class="mb-3">
<label for="pid" class="form-label">{% trans 'Document identifier' %}</label>
Expand Down Expand Up @@ -58,7 +58,7 @@ <h2 class="h4">{% trans 'Results for document' %} <strong>{{ pid }}</strong></h2

function update(){
xhr = $.ajax({
url: 'update_status/?task_id={{ task_id }}',
url: '/task/update_status/?task_id={{ task_id }}',
type: 'GET',
success: function(result) {
divSpinner = document.createElement('div');
Expand All @@ -75,16 +75,16 @@ <h2 class="h4">{% trans 'Results for document' %} <strong>{{ pid }}</strong></h2

if (result.data && 'doc_pkg' in result.data) {
clearInterval(intervals[0]);
userPackageDownloadCreateTable(result.data);
userPackageDownloadToggleSpinner();
ingressPackageDownloadCreateTable(result.data);
ingressPackageDownloadToggleSpinner();
}
}
});
}

if (checkStatus) {
intervals[0] = setInterval(update, 200);
userPackageDownloadToggleSpinner();
ingressPackageDownloadToggleSpinner();
}
</script>
{% endblock %}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{% block content %}
<div class="row justify-content-center pt-5">
<h1 class="h4">{% trans 'Change password' %}</h1>
<form class="bg-white border my-3 p-3 form-user" method="POST" action="{% url 'change_password' %}">
<form class="bg-white border my-3 p-3 form-user" method="POST" action="{% url 'user_change_password' %}">
{% csrf_token %}
<div class="mb-3">
<label for="old_password" class="form-label">{% trans 'Old password' %}</label>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
46 changes: 31 additions & 15 deletions spf/core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,38 @@
from . import views


urlpatterns = [
general = [
path('', views.index_page, name='index'),
path('register/', views.account_register_page, name='register'),
path('login/', views.account_login_page, name='login'),
path('change-password/', views.account_change_password_page, name='change_password'),
path('logout/', views.logout_user, name='logout'),
path('faq/', views.faq_page, name='faq'),
path('article/files/list', views.article_files_list_page, name='article_files_list'),
path('package/list', views.deposited_package_list_page, name='package_list'),
path('event/list', views.event_list_page, name='event_list'),
path('journal/list', views.journal_list_page, name='journal_list'),
path('user/add', views.user_add_page, name='user_add'),
path('user/package/upload', views.user_package_upload_page, name='user_package_upload'),
path('user/package/download', views.user_package_download_page, name='user_package_download'),
path('user/profile', views.user_profile_page, name='user_profile'),
path('user/profile/edit', views.user_profile_edit_page, name='user_profile_edit'),
]

user = [
path('register/', views.user_register_page, name='register'),
path('login/', views.user_login_page, name='login'),
path('logout/', views.user_logout, name='logout'),
path('user/add/', views.user_add_page, name='user_add'),
path('user/change_password/', views.user_change_password_page, name='user_change_password'),
path('user/groups/edit', views.user_groups_edit_page, name='user_groups_edit'),
url(r'^[\s\S]*/update_status/$', views.update_status, name='update_status'),
path('user/profile/', views.user_profile_page, name='user_profile'),
path('user/profile/edit/', views.user_profile_edit_page, name='user_profile_edit'),
]

ingress = [
path('ingress/package_upload/', views.ingress_package_upload_page, name='ingress_package_upload'),
path('ingress/package_download/', views.ingress_package_download_page, name='ingress_package_download'),
path('ingress/package_list/', views.ingress_package_list_page, name='ingress_package_list'),
path('ingress/articles_files/', views.ingress_articles_files_page, name='ingress_article_files_list'),
]


journal = [
path('journal/list/', views.journal_list_page, name='journal_list'),
]

tracking = [
path('event/list/', views.event_list_page, name='event_list'),
path('task/update_status/', views.task_update_status, name='task_update_status'),
]


urlpatterns = general + user + ingress + journal + tracking
Loading

0 comments on commit 184dc5f

Please sign in to comment.