Skip to content

Commit e058bd3

Browse files
committed
🔥 remove githubShowcase integration
1 parent 4b87dd0 commit e058bd3

13 files changed

Lines changed: 667 additions & 1184 deletions

File tree

‎connectors/githubShowcase/GitHubAPI.py‎

Lines changed: 0 additions & 36 deletions
This file was deleted.

‎connectors/githubShowcase/helpers.py‎

Lines changed: 0 additions & 68 deletions
This file was deleted.

‎projects/admin.py‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
11
from django.contrib import admin
2-
from .models import profile_register
3-
4-
5-
admin.site.register(profile_register)

‎projects/models.py‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,3 @@
22
from django.contrib.auth.models import User
33

44

5-
class profile_register(models.Model):
6-
user = models.TextField(max_length=200,default="")
7-
github_username = models.TextField(max_length=40,default="")
8-
9-
def __str__(self):
10-
return self.github_username

‎projects/urls.py‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,5 @@
33
app_name = "projects"
44

55
urlpatterns = [
6-
path(r'',views.index, name="index"),
7-
path(r'github-showcase/',views.githubShowcase,name="githubShowcase"),
8-
path(r'github-showcase/profile/<str:username>',views.profile,name="profile"),
9-
path(r'github-showcase/profile-add/',views.profile_add,name="add"),
6+
path(r'',views.index, name="index")
107
]

‎projects/views.py‎

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,9 @@
11
from django.shortcuts import redirect, render
22
from blog.models import Post
3-
from connectors.githubShowcase.GitHubAPI import get_data,check_github_username
4-
from .models import profile_register
3+
54
import json
65

76

87
def index(request):
98
blog = Post.objects.all()[:3]
109
return render(request,"projects/index.html",{"post":blog,'redirect_url':request.get_full_path()})
11-
12-
def profile_add(request):
13-
14-
if request.method == "POST":
15-
if request.user.is_authenticated and request.user.is_active:
16-
get_username = request.POST.get("username")
17-
if check_github_username(get_username):
18-
if is_profile_already(get_username):
19-
return render(request,"projects/GitHubShowcase/add_profile.html",{"error":"Profile already exits","url":True,"user":get_username})
20-
else:
21-
add_profile = profile_register.objects.create(github_username=get_username,user=request.user.username)
22-
add_profile.save()
23-
return redirect("/projects/github-showcase/profile/{}".format(get_username))
24-
else:
25-
return render(request,"projects/GitHubShowcase/add_profile.html",{"error":"No such GitHub username"})
26-
else:
27-
return render(request,"config/error.html",{"error":"By pass blocked"})
28-
else:
29-
if request.user.is_authenticated and request.user.is_active:
30-
if is_user_created_profile(request.user.username):
31-
return render(request,"config/error.html",{"error":"You can only create one profile with one account"})
32-
else:
33-
return render(request,"projects/GitHubShowcase/add_profile.html")
34-
else:
35-
return redirect("/account/login/?redirect-url={}".format(request.get_full_path()))
36-
37-
38-
def profile(request,username):
39-
if is_profile_already(username):
40-
try:
41-
if request.COOKIES['profile_data']:
42-
profile_data = json.loads(request.COOKIES['profile_data'])
43-
response = render(request,"projects/GitHubShowcase/profile.html",{"profile":profile_data,})
44-
except:
45-
profile_data = get_data(username)
46-
response = render(request,"projects/GitHubShowcase/profile.html",{"profile":profile_data})
47-
response.set_cookie(key='profile_data', value=json.dumps(profile_data),max_age=1800)
48-
49-
if profile_data is not None:
50-
try:
51-
if profile_data['RateLimits']:
52-
return render(request,"config/error.html",{"error":"GitHub API Rate Limits Exceeded , try after some time"})
53-
except:
54-
return response
55-
else:
56-
return render(request,"config/error.html",{"error":"Oops somethings went wrong, please contact support"})
57-
else:
58-
return render(request,"config/error.html",{"error":"No such profile found , create-account to create one"})
59-
60-
def githubShowcase(request):
61-
return render(request,'projects/GitHubShowcase/index.html')
62-
63-
def is_profile_already(github_username):
64-
query = profile_register.objects.filter(github_username=github_username).exists()
65-
return query
66-
67-
def is_user_created_profile(username):
68-
query = profile_register.objects.filter(user=username).exists()
69-
return query

0 commit comments

Comments
 (0)