Skip to content

Commit

Permalink
Merge pull request #349 from kumanik5661/library-upload
Browse files Browse the repository at this point in the history
LibrarySet modification issue
  • Loading branch information
firuza authored Aug 5, 2021
2 parents 6501f1a + 85a1591 commit 1343427
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions esim-cloud-backend/libAPI/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def toggle_default(self, request, obj, parent_obj=None):
)
library_set.save()
messages.info(request, mark_safe(
f"Library {obj.library_name} moved to '\
'<a href='/api/admin/libAPI/libraryset/{library_set.id}'>'\
'{library_set.name}</a>."))
f"Library {obj.library_name} moved to \
<a href='/api/admin/libAPI/libraryset/{library_set.id}'>\
{library_set.name}</a>."))
obj.library_set = library_set
obj.save()

Expand All @@ -75,7 +75,7 @@ def get_form(self, request, obj=None, **kwargs):
def save_model(self, request, obj, form, change):
# For new library set instance
User = get_user_model()
user = User.objects.get(id=request.POST.get('user'))
user = User.objects.get(id=request.user.id)
if obj.pk is None:
obj = LibrarySet(
user=user,
Expand All @@ -86,6 +86,8 @@ def save_model(self, request, obj, form, change):

# If the library set is being changed
else:
user = (LibrarySet.objects.get(id=obj.pk)).user
obj.user = user
obj.save()

files = request.FILES.getlist('files')
Expand Down
1 change: 1 addition & 0 deletions esim-cloud-backend/libAPI/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def __init__(self, *args, **kwargs):
instance = getattr(self, 'instance', None)
if instance and instance.pk:
self.fields['user'].widget.attrs['disabled'] = True
self.fields['user'].required = False
self.fields['name'].widget.attrs['readonly'] = True

class Meta:
Expand Down

0 comments on commit 1343427

Please sign in to comment.