Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mymusiclist
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Brian Guadalupe
mymusiclist
Commits
bbf6ea8a
Commit
bbf6ea8a
authored
Dec 07, 2017
by
Gink
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds playlist delete, song remove from playlist
parent
2f2fb374
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
49 additions
and
25 deletions
+49
-25
0001_initial.py
core/migrations/0001_initial.py
+1
-1
urls.py
mymusiclist/urls.py
+1
-1
views.py
playlist/views.py
+41
-19
base.html
templates/base.html
+2
-2
playlist.html
templates/playlist.html
+2
-0
profile.html
templates/profile.html
+1
-1
search.html
templates/search.html
+1
-1
No files found.
core/migrations/0001_initial.py
View file @
bbf6ea8a
# -*- coding: utf-8 -*-
# Generated by Django 1.11.
5 on 2017-11-19 11:12
# Generated by Django 1.11.
6 on 2017-12-07 01:37
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
...
...
mymusiclist/urls.py
View file @
bbf6ea8a
...
...
@@ -31,7 +31,7 @@ urlpatterns = [
url
(
r'^signup/$'
,
user_views
.
signup
,
name
=
'signup'
),
url
(
r'^search/$'
,
search_views
.
search
,
name
=
'search'
),
url
(
r'^playlist/(?P<identifier>[0-9]+)/$'
,
playlist_views
.
playlist_profile
,
name
=
'playlist_profile'
),
url
(
r'^manageplaylist/$'
,
playlist_views
.
addSong
,
name
=
'playlist_management'
),
url
(
r'^manageplaylist/$'
,
playlist_views
.
managePlaylist
,
name
=
'playlist_management'
),
url
(
r'^album/(?P<identifier>[0-9]+)/$'
,
search_views
.
album_profile
,
name
=
'album_profile'
),
url
(
r'^artist/(?P<identifier>[0-9]+)/$'
,
search_views
.
artist_profile
,
name
=
'artist_profile'
),
url
(
r'^profile/(?P<slug>[A-Za-z0-9-+_.@]+)/$'
,
user_views
.
user_profile_page
,
name
=
'viewprofile'
),
...
...
playlist/views.py
View file @
bbf6ea8a
...
...
@@ -9,14 +9,36 @@ from django.shortcuts import get_object_or_404
# Create your views here.
def
addSong
(
request
):
def
managePlaylist
(
request
):
response
=
HttpResponse
(
""
)
requesttype
=
request
.
GET
.
get
(
'type'
,
'1'
)
print
(
requesttype
)
if
(
not
request
.
user
.
is_authenticated
):
print
(
"no auth"
)
response
.
status_code
=
403
return
response
plname
=
request
.
GET
.
get
(
'playlist'
,
''
)
playlist
=
MusicPlaylist
.
objects
.
filter
(
user
=
request
.
user
,
playlist_name
=
plname
)
if
((
len
(
playlist
)
==
0
)
&
(
requesttype
==
"1"
)):
playlist
=
[
MusicPlaylist
(
playlist_name
=
plname
,
is_public
=
True
,
user
=
request
.
user
)]
playlist
[
0
]
.
save
()
elif
((
len
(
playlist
)
==
0
)
&
((
requesttype
==
"2"
)
|
(
requesttype
==
"3"
))):
print
(
"hihihi"
)
response
.
status_code
=
404
return
response
##REQUESTTYPE 1 = ADD
##REQUESTTYPE 2 = REMOVE
##REQUESTTYPE 3 = DELETE
if
(
requesttype
==
"3"
):
print
(
"hi"
)
playlist
[
0
]
.
delete
()
response
.
status_code
=
200
return
response
song
=
Song
.
objects
.
filter
(
id
=
request
.
GET
.
get
(
'song'
,
''
))
if
(
len
(
song
)
==
0
):
...
...
@@ -24,15 +46,15 @@ def addSong(request):
response
.
status_code
=
404
return
response
plname
=
request
.
GET
.
get
(
'playlist'
,
''
)
playlist
=
MusicPlaylist
.
objects
.
filter
(
user
=
request
.
user
,
playlist_name
=
plname
)
if
(
len
(
playlist
)
==
0
):
playlist
=
[
MusicPlaylist
(
playlist_name
=
"New"
,
is_public
=
True
,
user
=
request
.
user
)]
playlist
[
0
]
.
save
()
#MusicEntry Zone
if
(
requesttype
==
"2"
):
fil
=
MusicEntry
.
objects
.
filter
(
playlist
=
playlist
,
song
=
song
)
for
i
in
fil
:
fil
.
delete
()
response
.
status_code
=
200
return
response
if
(
requesttype
==
"1"
):
fil
=
MusicEntry
.
objects
.
filter
(
playlist
=
playlist
)
if
(
len
(
fil
)
==
0
):
high
=
0
...
...
templates/base.html
View file @
bbf6ea8a
...
...
@@ -69,7 +69,7 @@
<div>
{% block sidebar
%}
{% block sidebar
%}
<div
class=
"w3-card-4 w3-black w3-opacity sidebar"
>
<h2>
Featured Songs
</h2>
<img
src=
"/files/images/divide_edsheeran.jpeg"
alt=
"Divide - Ed Sheeran"
>
...
...
templates/playlist.html
View file @
bbf6ea8a
...
...
@@ -4,10 +4,12 @@
{% block sidebar %}
<div
class=
"w3-card-4 w3-black w3-opacity sidebar w3-round"
>
<p>
<b>
{{result.playlist_name}}
</b>
<br>
<br>
made by
<a
class =
"link"
href=
"/profile/{{owner.username}}"
>
{{owner.first_name}} {{owner.last_name}}
</a>
<br>
</div>
{% endblock %}
{% block content %}
...
...
templates/profile.html
View file @
bbf6ea8a
...
...
@@ -17,8 +17,8 @@
</ul>
{% if profile.username == request.user.username %}
<a
href=
"edit"
class=
"buttoned"
>
Edit user profile
</a>
</div>
{% endif %}
</div>
<div
class =
"boxified main profile"
>
<h2>
{{profile.username}}'s Playlists
</h2>
{% for i in playlists %}
...
...
templates/search.html
View file @
bbf6ea8a
...
...
@@ -150,7 +150,7 @@
}
}
};
xhttp
.
open
(
"GET"
,
"/manageplaylist/?song="
+
song
+
"&playlist="
+
plname
,
true
);
xhttp
.
open
(
"GET"
,
"/manageplaylist/?song="
+
song
+
"&playlist="
+
plname
+
"&type="
+
"1"
,
true
);
xhttp
.
setRequestHeader
(
"Content-type"
,
"application/x-www-form-urlencoded"
);
xhttp
.
send
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment