Skip to content

Commit

Permalink
style: static file changes
Browse files Browse the repository at this point in the history
  • Loading branch information
varundhand committed Aug 2, 2023
1 parent fc44bea commit f7ad4fb
Show file tree
Hide file tree
Showing 31 changed files with 141 additions and 30 deletions.
Empty file added .gitignore
Empty file.
Binary file modified devsearch/db.sqlite3
Binary file not shown.
Binary file modified devsearch/devsearch/__pycache__/urls.cpython-311.pyc
Binary file not shown.
Binary file modified devsearch/projects/__pycache__/forms.cpython-310.pyc
Binary file not shown.
Binary file modified devsearch/projects/__pycache__/models.cpython-311.pyc
Binary file not shown.
Binary file modified devsearch/projects/__pycache__/urls.cpython-311.pyc
Binary file not shown.
Binary file modified devsearch/projects/__pycache__/views.cpython-310.pyc
Binary file not shown.
Binary file modified devsearch/projects/__pycache__/views.cpython-311.pyc
Binary file not shown.
12 changes: 0 additions & 12 deletions devsearch/projects/templates/projects/delete_template.html

This file was deleted.

2 changes: 1 addition & 1 deletion devsearch/projects/templates/projects/project_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<main class="formPage my-xl">
<div class="content-box">
<div class="formWrapper">
<a class="backButton" href="#"><i class="im im-angle-left"></i></a>
<a class="backButton" href="{% url 'projects' %}"><i class="im im-angle-left"></i></a>
<br>

<form class="form" method="POST" enctype="multipart/form-data">
Expand Down
19 changes: 13 additions & 6 deletions devsearch/projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,40 @@ def project(request,pk):

@login_required(login_url='login')
def createProject(request):
profile = request.user.profile
form = ProjectForm()
if request.method == 'POST':
form = ProjectForm(request.POST,request.FILES)
if form.is_valid():
form.save()
return redirect('projects')
project = form.save(commit=False) # gives an instance of the project which we can use to iterate it
project.owner = profile #SETTING THE OWNER OF THE PROJECT # the owner of the project is the logged in user i.e. 'profile'
project.save()
return redirect('account')
context = {'form':form}
return render(request, 'projects/project_form.html',context)

@login_required(login_url='login')
def updateProject(request,pk):
project = Project.objects.get(id=pk)
profile = request.user.profile
project = profile.project_set.get(id=pk) # we will query only the LOGGED IN USER's projects so that another logged in used is not able to edit other's projects
form = ProjectForm(instance=project) #using instance to pre fill the form fields with project data
if request.method == 'POST':
form = ProjectForm(request.POST,request.FILES, instance=project)
if form.is_valid():
form.save()
return redirect('projects')
return redirect('account')
context = {'form':form}
return render(request, 'projects/project_form.html',context)

@login_required(login_url='login')
def deleteProject(request,pk):
project = Project.objects.get(id=pk)
profile = request.user.profile # QUERYING LOGGED IN USER'S PROJECTS ONLY so that only the OWNER OF PROJECT could delete it
project = profile.project_set.get(id=pk)
if request.method == 'POST':
project.delete()
return redirect('projects')

context = {'object':project}
return render(request, 'projects/delete_template.html',context)
return render(request, 'delete_template.html',context)


Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed devsearch/static/images/profiles/yeet.gif
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added devsearch/staticfiles/images/profiles/yeet3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions devsearch/templates/delete_template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% extends 'main.html' %}
{% block content %}
<!-- using a form to accept a post request -->
<!-- <form action="" method="POST">
{% csrf_token %}
<p>Are you sure you want to delete "{{object}}"</p>
<button><a href="{% url 'projects' %}"> Cancel</a></button>
<input type="submit" value="confirm">
</form> -->

<main class="formPage my-xl">
<div class="content-box">
<div class="formWrapper">

<br>

<form class="form" method="POST" action="">
{% csrf_token %}
<p>Are you sure you want to delete "{{object}}"</p>
<a class="btn btn--sub btn--lg my-md" href="{{request.GET.next}}">Go Back</a>

<input class="btn btn--sub btn--lg my-md" type="submit" value="Confirm" />
</form>
</div>
</div>
</main>

{% endblock %}
1 change: 1 addition & 0 deletions devsearch/templates/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<link rel="stylesheet" href="{% static 'uikit/styles/uikit.css'%}" />
<!-- Dev Search UI -->
<link rel="stylesheet" href="{% static 'styles/app.css' %}" />
<!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/material-design-iconic-font/2.2.0/css/material-design-iconic-font.min.css"> -->

<title>DevSearch - Connect with Developers!</title>
</head>
Expand Down
Binary file modified devsearch/users/__pycache__/apps.cpython-311.pyc
Binary file not shown.
Binary file modified devsearch/users/__pycache__/models.cpython-310.pyc
Binary file not shown.
Binary file modified devsearch/users/__pycache__/models.cpython-311.pyc
Binary file not shown.
Binary file modified devsearch/users/__pycache__/signals.cpython-310.pyc
Binary file not shown.
Binary file modified devsearch/users/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file modified devsearch/users/__pycache__/views.cpython-310.pyc
Binary file not shown.
15 changes: 13 additions & 2 deletions devsearch/users/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.forms import ModelForm
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
from .models import Profile
from .models import Profile, Skill

#for login and regitser page
class CustomUserCreationForm(UserCreationForm):
Expand All @@ -21,8 +21,19 @@ def __init__(self, *args, **kwargs): # FOR STYLING
class ProfileForm(ModelForm):
class Meta:
model = Profile
fields = ['name','email','username','location','bio','short_intro','profile_image','social_github','social_linkedin','social_twitter','social_youtube','social_website']
fields = ['name','email','username','location','bio','short_intro','profile_image','social_github','social_linkedin','social_twitter','social_youtube','social_website'] #could have used exclude instaed of this long syntax
def __init__(self, *args, **kwargs): # FOR STYLING
super(ProfileForm,self).__init__(*args,**kwargs)
for name,field in self.fields.items():
field.widget.attrs.update({'class':'input'})


class SkillForm(ModelForm):
class Meta:
model = Skill
fields = '__all__'
exclude = ['owner']
def __init__(self, *args, **kwargs): # FOR STYLING
super(SkillForm,self).__init__(*args,**kwargs)
for name,field in self.fields.items():
field.widget.attrs.update({'class':'input'})
4 changes: 3 additions & 1 deletion devsearch/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Profile(models.Model):
location = models.CharField(max_length=200,blank=True,null=True)
short_intro = models.CharField(max_length=200,blank=True,null=True)
bio = models.TextField(blank=True,null=True)
profile_image = models.ImageField(null=True,blank=True,upload_to='profiles/',default='profiles/user-default.png')
profile_image = models.ImageField(null=True,blank=True,upload_to='profiles/',default='profiles/user-default.png') #profiles in static folder within images
social_github = models.CharField(max_length=200, blank=True, null=True)
social_twitter = models.CharField(max_length=200, blank=True, null=True)
social_linkedin = models.CharField(max_length=200, blank=True, null=True)
Expand All @@ -36,3 +36,5 @@ class Skill(models.Model):

def __str__(self):
return str(self.name)

# class Meta: # META DATA provides information about other data. so here meta tags can be used to provide information about the django model
12 changes: 6 additions & 6 deletions devsearch/users/templates/users/account.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ <h3 class="devInfo__title">About Me</h3>
</div>
<div class="settings">
<h3 class="settings__title">Skills</h3>
<a class="tag tag--pill tag--sub settings__btn tag--lg" href="#"><i class="im im-plus"></i> Add Skill</a>
<a class="tag tag--pill tag--sub settings__btn tag--lg" href="{% url 'create-skill' %}"><i class="im im-plus"></i> Add Skill</a>
</div>

<table class="settings__table">
Expand All @@ -70,8 +70,8 @@ <h4>{{skill.name}}</h4>
</p>
</td>
<td class="settings__tableActions">
<a class="tag tag--pill tag--main settings__btn" href="#"><i class="im im-edit"></i> Edit</a>
<a class="tag tag--pill tag--main settings__btn" href="#"><i class="im im-x-mark-circle-o"></i>
<a class="tag tag--pill tag--main settings__btn" href="{% url 'update-skill' skill.id %}"><i class="im im-edit"></i> Edit</a>
<a class="tag tag--pill tag--main settings__btn" href="{% url 'delete-skill' skill.id %}?next=/account"><i class="im im-x-mark-circle-o"></i>
Delete</a>
</td>
</tr>
Expand All @@ -80,7 +80,7 @@ <h4>{{skill.name}}</h4>

<div class="settings">
<h3 class="settings__title">Projects</h3>
<a class="tag tag--pill tag--sub settings__btn tag--lg" href="#"><i class="im im-plus"></i> Add Project</a>
<a class="tag tag--pill tag--sub settings__btn tag--lg" href="{% url 'create-project' %}"><i class="im im-plus"></i> Add Project</a>
</div>

<table class="settings__table">
Expand All @@ -96,8 +96,8 @@ <h3 class="settings__title">Projects</h3>
</p>
</td>
<td class="settings__tableActions">
<a class="tag tag--pill tag--main settings__btn" href="#"><i class="im im-edit"></i> Edit</a>
<a class="tag tag--pill tag--main settings__btn" href="#"><i class="im im-x-mark-circle-o"></i>
<a class="tag tag--pill tag--main settings__btn" href="{% url 'update-project' project.id %}"><i class="im im-edit"></i> Edit</a>
<a class="tag tag--pill tag--main settings__btn" href="{% url 'delete-project' project.id %}?next=/account"><i class="im im-x-mark-circle-o"></i>
Delete</a>
</td>
</tr>
Expand Down
26 changes: 26 additions & 0 deletions devsearch/users/templates/users/skill_form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% extends 'main.html' %}

{% block content %}


<main class="formPage my-xl">
<div class="content-box">
<div class="formWrapper">
<a class="backButton" href="{% url 'account' %}"><i class="im im-angle-left"></i></a>
<br>

<form class="form" method="POST" action="">
{% csrf_token %}
{% for field in form %}
<div class="form__field">
<label for="formInput#text">{{field.label}}: </label>
{{field}}
</div>
{% endfor %}
<input class="btn btn--sub btn--lg my-md" type="submit" value="Submit" />
</form>
</div>
</div>
</main>

{% endblock%}
4 changes: 4 additions & 0 deletions devsearch/users/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@
path('account/',views.userAccount,name='account'),

path('edit-account/', views.editAccount, name='edit-account'),

path('create-skill/', views.createSkill, name='create-skill'),
path('update-skill/<str:pk>/', views.updateSkill, name='update-skill'),
path('delete-skill/<str:pk>/', views.deleteSkill, name='delete-skill'),
]
48 changes: 46 additions & 2 deletions devsearch/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from .models import *
from .forms import CustomUserCreationForm,ProfileForm
from .forms import CustomUserCreationForm,ProfileForm,SkillForm

# Create your views here.
def loginUser(request):
Expand Down Expand Up @@ -92,4 +92,48 @@ def editAccount(request):
form.save()
return redirect('account')
context = {'form':form}
return render(request,'users/profile_form.html',context)
return render(request,'users/profile_form.html',context)

@login_required(login_url='login')
def createSkill(request):
profile = request.user.profile
form = SkillForm()

if request.method == 'POST':
form = SkillForm(request.POST)
if form.is_valid():
skill = form.save(commit=False)
skill.owner = profile
skill.save()
messages.success(request,'Skill was added successfully!')
return redirect('account')

context = {'form':form}
return render(request, 'users/skill_form.html',context )

@login_required(login_url='login')
def updateSkill(request, pk):
profile = request.user.profile
skill = profile.skill_set.get(id=pk)
form = SkillForm(instance=skill)

if request.method == 'POST':
form = SkillForm(request.POST,instance=skill)
if form.is_valid():
form.save()
messages.success(request,'Skill was updated successfully!')
return redirect('account')

context = {'form':form}
return render(request, 'users/skill_form.html',context )

def deleteSkill(request,pk):
profile = request.user.profile
skill = profile.skill_set.get(id=pk)
if request.method == 'POST':
skill.delete()
messages.success(request,'Skill was deleted successfully!')
return redirect('account')

context= {'object':skill}
return render(request, 'delete_template.html',context)

0 comments on commit f7ad4fb

Please sign in to comment.