aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobby <[email protected]>2022-11-21 23:33:24 -0500
committerBobby <[email protected]>2022-11-21 23:33:24 -0500
commit483adbdabee305c992052e81d7a26a96fa9b1eaa (patch)
treee3a3503456bfbbef61791404318a13f4294ae695
parenteffa0acbea7bd444fb772fec944db769dd65295b (diff)
downloadthatcomputerscientist-483adbdabee305c992052e81d7a26a96fa9b1eaa.tar.xz
thatcomputerscientist-483adbdabee305c992052e81d7a26a96fa9b1eaa.zip
repository code refactor
-rw-r--r--dev_status/views.py12
1 files changed, 3 insertions, 9 deletions
diff --git a/dev_status/views.py b/dev_status/views.py
index a869a653..4914305a 100644
--- a/dev_status/views.py
+++ b/dev_status/views.py
@@ -11,20 +11,15 @@ g = Github(os.getenv('GH_TOKEN'))
def home(request):
page = request.GET.get('page') or 1
items = request.GET.get('items') or 10
- filter = request.GET.get('filter') or 'all'
+ filter = request.GET.get('filter') or 'public'
sort = request.GET.get('sort') or 'updated'
direction = request.GET.get('direction') or 'desc'
search = request.GET.get('search') or ''
if not request.user.is_authenticated:
filter = 'public'
context = {}
- repos = g.get_user().get_repos(type=filter, sort=sort, direction=direction)
-
- if search != '':
- search = search.lower()
- repos = [repo for repo in repos if search in str(repo.name).lower() or search in str(repo.description).lower()]
- repos = [repo for repo in repos if 'luciferreeves' in str(repo.full_name).lower()]
-
+ repo_rl = g.get_user().get_repos(type=filter, sort=sort, direction=direction)
+ repos = [repo for repo in repo_rl if (search.lower() in str(repo.name).lower() or search in str(repo.description).lower()) and 'luciferreeves' in str(repo.full_name).lower()] if search != '' else [repo for repo in repo_rl if 'luciferreeves' in str(repo.full_name).lower()]
context['repo_length'] = len(repos)
context['repos'] = repos[(int(page) - 1) * int(items):int(page) * int(items)]
context['title'] = '{} Repositories'.format(str(filter).capitalize())
@@ -35,7 +30,6 @@ def home(request):
context['sort'] = sort
context['direction'] = direction
context['search'] = search
- print(context)
return render(request, 'dev_status/home.html', context)