Skip to content

Commit

Permalink
Get User Preference View added
Browse files Browse the repository at this point in the history
  • Loading branch information
DEKHTIARJonathan committed Sep 6, 2017
1 parent e0a6d32 commit 13756c4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions feedcrunch_api_v1/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
# User Routes
url(r'^authenticated/get/user/publications_stats/$', User_Stats_Publications.as_view(), name='publications_stats'),
url(r'^authenticated/get/user/subscribers_stats/$', User_Stats_Subscribers.as_view(), name='subscribers_stats'),
url(r'^authenticated/get/user/preferences/$', User_Preferences.as_view(), name='get_user_preferences'),
url(r'^authenticated/modify/user/social-networks/slack/$', Modify_Slack_Preferences.as_view(), name='modify_slack_preferences'),
url(r'^authenticated/modify/user/social-networks/$', Modify_Social_Networks.as_view(), name='modify_social_networks'),
url(r'^authenticated/modify/user/personal-info/$', Modify_Personal_info.as_view(), name='modify_personal_info'),
Expand Down
25 changes: 25 additions & 0 deletions feedcrunch_api_v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,31 @@ def put(self, request):
class User_Preferences(APIView):
permission_classes = (IsAuthenticated, )

def get(self, request):

payload = dict()

try:
payload["preferences"] = dict()

payload["preferences"]["visibility"] = request.user.pref_post_public_visibility
payload["preferences"]["autoformat"] = request.user.pref_post_autoformat
payload["preferences"]["twitter"] = request.user.pref_post_repost_TW
payload["preferences"]["facebook"] = request.user.pref_post_repost_FB
payload["preferences"]["linkedin"] = request.user.pref_post_repost_LKin
payload["preferences"]["slack"] = request.user.pref_post_repost_Slack

payload["success"] = True

except Exception as e:
payload["error"] = "User_Preferences - GET: " + str(e)
payload["success"] = False

payload ["operation"] = "Get personal preferences"
payload ["timestamp"] = get_timestamp()

return Response(payload)

def put(self, request):

payload = dict()
Expand Down

0 comments on commit 13756c4

Please sign in to comment.