Skip to content

Commit

Permalink
Merge pull request #1548 from laws-africa/bulk-import-attorneys
Browse files Browse the repository at this point in the history
Bulk import attorneys
  • Loading branch information
nickmwangemi authored Sep 25, 2023
2 parents 6dcebcc + 27dc34b commit 8e08f2a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
8 changes: 7 additions & 1 deletion peachjam/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
)
from peachjam.resources import (
ArticleResource,
AttorneyResource,
GenericDocumentResource,
JudgmentResource,
UserResource,
Expand Down Expand Up @@ -1008,10 +1009,15 @@ class MatterTypeAdmin(BaseAdmin):
help_topic = "site-admin/add-matter-types"


@admin.register(Attorney)
class AttorneyAdmin(ImportExportMixin, admin.ModelAdmin):
resource_class = AttorneyResource
list_display = ("name", "description")


admin.site.register(
[
CitationLink,
Attorney,
CourtClass,
AttachedFileNature,
CitationProcessing,
Expand Down
13 changes: 12 additions & 1 deletion peachjam/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@ def clean(self, value, row=None, *args, **kwargs):

class ManyToManyFieldWidget(ManyToManyWidget):
def clean(self, value, row=None, *args, **kwargs):

# Remove extra white space around and in between the judges' or attorneys' names
if value:
items = [" ".join(j.split()) for j in value.split(self.separator)]
Expand Down Expand Up @@ -674,3 +673,15 @@ def before_save_instance(self, instance, using_transactions, dry_run):
instance.password = make_password(instance.password)
instance.is_staff = True
instance.save()


class AttorneyResource(resources.ModelResource):
description = fields.Field(
column_name="description",
attribute="description",
widget=CharWidget(),
default="",
)

class Meta:
model = Attorney

0 comments on commit 8e08f2a

Please sign in to comment.