-
-
Notifications
You must be signed in to change notification settings - Fork 775
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf58dbb
commit 8c4f877
Showing
4 changed files
with
218 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
let users = []; | ||
let usersPage = 1; | ||
let usersNumPages = ''; | ||
let usersHasNext = false; | ||
|
||
Vue.mixin({ | ||
methods: { | ||
fetchUsers: function(newPage) { | ||
var vm = this; | ||
|
||
if (newPage) { | ||
vm.usersPage = newPage; | ||
} | ||
|
||
var getNotifications = fetchData (`/api/v0.1/users_fetch/?page=${vm.usersPage}`, 'GET'); | ||
|
||
$.when(getNotifications).then(function(response) { | ||
newNotifications = newData(response.data, vm.notifications); | ||
newNotifications.forEach(function(item) { | ||
vm.notifications.push(item); | ||
}); | ||
|
||
vm.usersNumPages = response.num_pages; | ||
vm.usersHasNext = response.has_next; | ||
vm.numNotifications = response.count; | ||
|
||
vm.checkUnread(); | ||
if (vm.usersHasNext) { | ||
vm.usersPage = ++vm.usersPage; | ||
|
||
} else { | ||
vm.usersPage = 1; | ||
} | ||
}); | ||
} | ||
|
||
} | ||
|
||
}); | ||
|
||
if (document.getElementById('gc-users-directory')) { | ||
var app = new Vue({ | ||
delimiters: [ '[[', ']]' ], | ||
el: '#gc-users-directory', | ||
data: { | ||
users, | ||
usersPage, | ||
usersNumPages, | ||
usersHasNext | ||
}, | ||
mounted() { | ||
this.fetchUsers(); | ||
}, | ||
created() { | ||
// this.sendState(); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -731,8 +731,8 @@ def onboard(request, flow): | |
return TemplateResponse(request, 'ftux/onboard.html', params) | ||
|
||
|
||
def users(request): | ||
"""Handle displaying the users.""" | ||
def users_directory(request): | ||
"""Handle displaying users directory page.""" | ||
|
||
# q = request.GET.get('q') | ||
order_by = request.GET.get('order_by', '-created_on') | ||
|
@@ -757,6 +757,54 @@ def users(request): | |
} | ||
return TemplateResponse(request, 'dashboard/users.html', params) | ||
|
||
|
||
@require_GET | ||
def users_fetch(request): | ||
"""Handle displaying users.""" | ||
# order_by = request.GET.get('order_by', '-created_on') | ||
# query_kwargs = { | ||
|
||
# } | ||
# user_list = Profile.objects.all() | ||
# users = user_list.order_by(order_by).cache() | ||
|
||
# params = { | ||
# 'active': 'users', | ||
# 'title': 'Users', | ||
# 'meta_title': "", | ||
# 'meta_description': "", | ||
# 'users': users, | ||
# 'keywords': json.dumps([str(key) for key in Keyword.objects.all().values_list('keyword', flat=True)]), | ||
# } | ||
|
||
|
||
limit = int(request.GET.get('limit', 10)) | ||
page = int(request.GET.get('page', 1)) | ||
order_by = request.GET.get('order_by', '-created_on') | ||
user_list = Profile.objects.all() | ||
users = user_list.order_by(order_by).cache() | ||
# all_notifs = Notification.objects.filter(to_user_id=request.user.id).order_by('-id') | ||
params = dict() | ||
all_pages = Paginator(users, limit) | ||
if page <= 0 or page > all_pages.num_pages: | ||
page = 1 | ||
all_users = [] | ||
# all_users = all_pages.page(page) | ||
for user in all_pages.page(page): | ||
print(user) | ||
profile_json = {} | ||
if user.avatar_baseavatar_related.exists(): | ||
profile_json['avatar_id'] = user.avatar_baseavatar_related.first().pk | ||
profile_json['avatar_url'] = user.avatar_baseavatar_related.first().avatar_url | ||
profile_json = user.to_standard_dict() | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
octavioamu
Author
Contributor
|
||
all_users.append(profile_json) | ||
params['data'] = json.dumps(all_users) | ||
params['has_next'] = all_pages.page(page).has_next() | ||
params['count'] = all_pages.count | ||
params['num_pages'] = all_pages.num_pages | ||
return JsonResponse(params, status=200, safe=False) | ||
|
||
|
||
def dashboard(request): | ||
"""Handle displaying the dashboard.""" | ||
|
||
|
i wish we had done a better job of scrubbing this standard dict of private info (slack token, email, github access token, etc) before launching @danlipert @octavioamu