Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collections #1810

Draft
wants to merge 35 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
813bd48
collections app creation and first basic implementations
quimmrc Jan 8, 2025
52543c4
migration: add collection attributes
quimmrc Jan 9, 2025
5f137eb
attempt to implement collection modals
quimmrc Jan 16, 2025
51adc61
models reformulation
quimmrc Jan 21, 2025
13a90da
Merge branch 'master' into collections
quimmrc Jan 22, 2025
2780959
add sound modal behavior tbd
quimmrc Jan 23, 2025
4c7c190
add sound modal collection selector
quimmrc Jan 23, 2025
0f47090
add sound to col from sound url
quimmrc Jan 23, 2025
fc55074
delete sound from collection func.
quimmrc Jan 23, 2025
b2e0277
deletion for CollectionSound + restrict add duplicates
quimmrc Jan 24, 2025
5ba088d
minor details correction
quimmrc Jan 24, 2025
ae9950b
delete and create collection functionalities
quimmrc Jan 27, 2025
d679849
Edit collection permissions
quimmrc Jan 28, 2025
58d845f
add collection parameter to settings.py
quimmrc Jan 28, 2025
3d7a668
add maintainer modal (fails)
quimmrc Jan 29, 2025
5ffea0b
add maintainers interface
quimmrc Jan 30, 2025
d5fed09
adequate variable namings for collection modals
quimmrc Jan 30, 2025
04ba23d
maintainers display in edit collection url
quimmrc Feb 3, 2025
e2bc70a
Merge branch 'master' into collections
quimmrc Feb 3, 2025
18c9548
changes from github review
quimmrc Feb 4, 2025
034528c
Merge branch 'master' into collections
quimmrc Feb 4, 2025
f62d388
db update + review + collect sound small player
quimmrc Feb 5, 2025
81affae
add sound to collection for all sound displays
quimmrc Feb 5, 2025
79787d1
remove maintainers from edit page
quimmrc Feb 6, 2025
82b3e2a
add maintainers
quimmrc Feb 6, 2025
d8fe151
Initial tests + create collections from scratch
quimmrc Feb 7, 2025
058d326
enable bookmark collection + public/private edition
quimmrc Feb 12, 2025
8fd039a
add sounds from small player + display Json success msg
quimmrc Feb 12, 2025
cd609e0
download collections
quimmrc Feb 13, 2025
f64d1b2
tests and miscellanious
quimmrc Feb 17, 2025
ff18e6b
order paginator query
quimmrc Feb 17, 2025
6a4d773
edit collection: sound display + bulk and adding maintainers temporary
quimmrc Feb 25, 2025
21cce70
users selectable for maintainers display
quimmrc Feb 25, 2025
33bcc39
add and remove maintainers through modal
quimmrc Mar 4, 2025
fb104f3
collections display approach
quimmrc Mar 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
minor details correction
quimmrc committed Jan 24, 2025
commit 5ba088d8b53d1a68a97e6170b77bdd53c608a447
15 changes: 4 additions & 11 deletions fscollections/forms.py
Original file line number Diff line number Diff line change
@@ -51,16 +51,15 @@ def __init__(self, *args, **kwargs):
self.user_collections = kwargs.pop('user_collections', False)
self.user_saving_sound = kwargs.pop('user_saving_sound', False)
self.sound_id = kwargs.pop('sound_id', False)

if self.user_collections:
self.user_available_collections = Collection.objects.filter(id__in=self.user_collections).exclude(collectionsound__sound__id=self.sound_id)
print(self.user_available_collections)
print(self.sound_id)
print(self.user_collections)

super().__init__(*args, **kwargs)
self.fields['collection'].choices = [(self.NO_COLLECTION_CHOICE_VALUE, '--- No collection ---'),#in this case this goes to bookmarks collection (might have to be created)
(self.NEW_COLLECTION_CHOICE_VALUE, 'Create a new collection...')] + \
([(collection.id, collection.name) for collection in self.user_available_collections ]
if self.user_collections else[])
if self.user_available_collections else[])

self.fields['new_collection_name'].widget.attrs['placeholder'] = "Fill in the name for the new collection"
self.fields['collection'].widget.attrs = {
@@ -80,18 +79,12 @@ def save(self, *args, **kwargs):
collection_to_use = collection
else:
collection_to_use = Collection.objects.get(id=self.cleaned_data['collection'])
else: #en aquest cas - SÍ estem fent servir l'última coleccio, NO estem creant una nova coleccio, NO estem agafant una coleccio existent i
# per tant ens trobem en un cas de NO COLLECTION CHOICE VALUE (no s'ha triat cap coleccio)
# si no es tria cap coleccio: l'usuari té alguna colecció? NO -> creem BookmarksCollection pels seus sons privats
# SI -> per defecte es posa a BookmarksCollection
else:
try:
last_user_collection = \
Collection.objects.filter(user=self.user_saving_sound).order_by('-created')[0]
# If user has a previous bookmark, use the same category (or use none if no category used in last
# bookmark)
collection_to_use = last_user_collection
except IndexError:
# This is first bookmark of the user
pass
# If collection already exists, don't save it and return the existing one
collection, _ = Collection.objects.get_or_create(
15 changes: 6 additions & 9 deletions fscollections/views.py
Original file line number Diff line number Diff line change
@@ -38,9 +38,9 @@ def collections_for_user(request, collection_id=None):
user = request.user
user_collections = Collection.objects.filter(user=user).order_by('-created')
is_owner = False
#if no collection id is provided for this URL, render the oldest collection
#be careful when loading this url without having any collection for a user
#only show the collections for which you're the user(owner)
# if no collection id is provided for this URL, render the oldest collection
# be careful when loading this url without having any collection for a user
# only show the collections for which you're the user(owner)

if not collection_id:
collection = user_collections.last()
@@ -65,8 +65,8 @@ def collections_for_user(request, collection_id=None):
#NOTE: tbd - when a user wants to save a sound without having any collection, create a personal bookmarks collection

def add_sound_to_collection(request, sound_id):
#this view from now on should create a new CollectionSound object instead of adding
#a sound to collection.sounds
# this view from now on should create a new CollectionSound object instead of adding
# a sound to collection.sounds
# TODO: add restrictions for sound repetition and for user being owner/maintainer
sound = get_object_or_404(Sound, id=sound_id)
msg_to_return = ''
@@ -95,8 +95,7 @@ def add_sound_to_collection(request, sound_id):
def delete_sound_from_collection(request, collectionsound_id):
#this should work as in Packs - select several sounds and remove them all at once from the collection
#by now it works as in Bookmarks in terms of UI
#TODO: this should be done through a POST request method, would be easier to send CollectionSound ID and delete it directly
# this would save up a query
#TODO: this should be done through a POST request method
collection_sound = get_object_or_404(CollectionSound, id=collectionsound_id)
collection = collection_sound.collection
collection_sound.delete()
@@ -122,8 +121,6 @@ def get_form_for_collecting_sound(request, sound_id):
user_collections=user_collections)

collections_already_containing_sound = Collection.objects.filter(user=request.user, collectionsound__sound__id=sound.id).distinct()
# collect_sound_url = '/'.join(
# request.build_absolute_uri(reverse('add-sound-to-collection', args=[sound_id])).split('/')[:-2]) + '/'
tvars = {'user': request.user,
'sound': sound,
'sound_is_moderated_and_processed_ok': sound.moderated_and_processed_ok,