Skip to content

Commit

Permalink
tools(format): update export forms, move to admin site
Browse files Browse the repository at this point in the history
Signed-off-by: pamfilos <[email protected]>
  • Loading branch information
pamfilos committed Sep 16, 2024
1 parent 6f3b157 commit 584e9ef
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
6 changes: 5 additions & 1 deletion config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
"about/", TemplateView.as_view(template_name="pages/about.html"), name="about"
),
# Django Admin, use {% url 'admin:index' %}
path(settings.ADMIN_URL + "tools/", admin.site.admin_view(ExportView.as_view()), name="admin_tools"),
path(
settings.ADMIN_URL + "tools/",
admin.site.admin_view(ExportView.as_view()),
name="admin_tools",
),
path(settings.ADMIN_URL, admin.site.urls),
path("select2/", include("django_select2.urls")),
# User management
Expand Down
19 changes: 8 additions & 11 deletions scoap3/exports/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,22 @@

from scoap3.misc.models import Country


class CountryWidget(ModelSelect2Widget):
search_fields = [
"code__icontains",
"name__icontains"
]
search_fields = ["code__icontains", "name__icontains"]


class Country2Widget(ModelSelect2Widget):
search_fields = [
"code__icontains",
"name__icontains"
]
search_fields = ["code__icontains", "name__icontains"]


class AffiliationExportForm(forms.Form):
aff_year = forms.IntegerField(label="Year", required=True)
aff_country = forms.ModelChoiceField(
queryset=Country.objects.all(),
widget=Country2Widget,
label="Country",
required=True
required=True,
)


Expand All @@ -31,5 +28,5 @@ class AuthorExportForm(forms.Form):
queryset=Country.objects.all(),
widget=CountryWidget,
label="Country",
required=True
)
required=True,
)
5 changes: 3 additions & 2 deletions scoap3/exports/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from datetime import datetime

from django.contrib import messages
from django.contrib.auth.mixins import PermissionRequiredMixin

# from django.contrib.auth.mixins import PermissionRequiredMixin
from django.http import HttpResponse
from django.views.generic.edit import FormView

Expand All @@ -27,7 +28,7 @@ def generate_csv_response(data, action_name, write_header=True):
return response


class ExportView( FormView):
class ExportView(FormView):
# permission_required = "users.partner_export"
template_name = "admin/tools.html"
form_class = AffiliationExportForm
Expand Down
1 change: 1 addition & 0 deletions scoap3/misc/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Meta:
def __str__(self):
return f"{self.name} ({self.code})"


class Affiliation(models.Model):
author_id = models.ManyToManyField("authors.Author", blank=True)
country = models.ForeignKey("misc.Country", on_delete=models.CASCADE, null=True)
Expand Down

0 comments on commit 584e9ef

Please sign in to comment.