Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ website/db.sqlit
.env
.venv
env/
myEnv/
venv/
ENV/
env.bak/
Expand All @@ -83,4 +84,6 @@ website/events_calendar/migrations/
website/migrations/

# Media files
media/
media/

staticfiles/
Binary file modified new_requirements.txt
Binary file not shown.
40 changes: 40 additions & 0 deletions new_requirements2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
asgiref==3.8.1
beautifulsoup4==4.11.1
certifi==2023.11.17
cffi==1.16.0
charset-normalizer==2.1.1
cryptography==41.0.7
defusedxml==0.7.1
dj-database-url==0.5.0
Django==3.2.25
django-cors-headers==3.13.0
django-filter==22.1
django-markdownx==3.0.1
django-prometheus==2.2.0
django-widget-tweaks==1.4.12
djangorestframework==3.14.0
djangorestframework-simplejwt==5.2.2
html2markdown==0.1.7
idna==3.4
Markdown==3.4.1
mysqlclient==2.2.6
oauthlib==3.2.2
Pillow==10.1.0
prometheus-client==0.15.0
pycparser==2.21
PyJWT==2.10.1
python-dateutil==2.8.2
python-decouple==3.6
python-dotenv==1.0.1
python3-openid==3.2.0
pytz==2023.3.post1
requests==2.31.0
requests-oauthlib==1.3.1
six==1.16.0
social-auth-app-django==5.4.2
social-auth-core==4.5.4
soupsieve==2.3.2.post1
sqlparse==0.4.4
typing_extensions==4.12.2
tzdata==2024.2
urllib3==2.1.0
73 changes: 41 additions & 32 deletions website/blog/templates/blog/blog_list.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{% load static %}
{% load blog_tags %}

{% for post in posts %}
<li class="col-sm-12 col-lg-12 ques_div mt-2 mb-1" id="content">
<ul id="attributeList">
Expand All @@ -7,56 +9,63 @@
<div class="col-sm-1 col-lg-1 mr-2">
{% for p in profile %}
{% if p.user == post.user_id %}
<img src="{{ p.image.url }}" class="rounded-circle mt-2 mb-1" width="55px" height="55px" alt="img">
{% if p.image %}
<img src="{{ p.image.url }}" class="rounded-circle mt-2 mb-1" width="55px" height="55px" alt="img">
{% else %}
<img src="{% static 'image/profile_pic/default.png' %}" class="rounded-circle mt-2 mb-1" width="55px" height="55px" alt="default">
{% endif %}
{% endif %}
{% endfor %}
</div>

<div class="col-lg-6 col-sm-12">
<div>
<a id="questionDetail" href="{% url 'blog:detail_blogs' post.id %}">
<a id="questionDetail" href="{% url 'blog:detail_blogs' post.id %}">
<strong>{{ post.title }}</strong>
</a>
<br>
</div>

<div id="addedBy" class="text-muted">
<li>Posted by <a href="{% url 'user_profile:view_profile' post.user_id.id %}">{{post.user_id}}</a> on</li>
<li>Posted by <a href="{% url 'user_profile:view_profile' post.user_id.id %}">{{ post.user_id }}</a> on</li>
</div>
<li id="postedOn" class="text-muted">{{post.created_at}}</li>

<li id="postedOn" class="text-muted">{{ post.created_at }}</li>
<br>

<li id="tagList">
<ul>
{% for tagging in taggings %}
{% if tagging.post == post %}
{% for tag in tags %}
{% if tagging.tag == tag %}
{% comment %} <li class="tagName" class="font-italic text-muted">{{tag.name}}</li> {% endcomment %}
<li style="display:inline-block;"><a class="tagName" href="{% url 'blog:filter_blog' tag.id %}">{{ tag.name }}</a></li>
{% endif %}
{% endfor %}
{%endif%}
{% for tagging in taggings %}
{% if tagging.post == post %}
{% for tag in tags %}
{% if tagging.tag == tag %}
<li style="display:inline-block;">
<a class="tagName" href="{% url 'blog:filter_blog' tag.id %}">{{ tag.name }}</a>
</li>
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
</ul>
</li>
</div>
<!-- <div id="AnswerFollow_block" style="display: inline-block;"> -->
<div class="col-sm-5 col-md-3 col-lg-3 mt-auto mb-auto" id="answerBox" style="display: inline-block;">
<div class="row">
<div class="col-sm-6">
{%if post.reply_set.count == 1 %}
<span id="followValue" style="font-size:70%;">{{ post.reply_set.count }} comment
{%else %}
<span id="followValue" style="font-size:70%;">{{ post.reply_set.count }} comments
{%endif%}
</span>
</div>
<div class="col-sm-5 col-md-3 col-lg-6" id="followBox" style="display: inline-block;">
<span id="followValue" style="font-size:70%;">{{post.id|postlike_count}} vote(s)</span>
</div>
</div>

<div class="col-sm-5 col-md-3 col-lg-3 mt-auto mb-auto" id="answerBox" style="display:inline-block;">
<div class="row">
<div class="col-sm-6">
{% if post.reply_set.count == 1 %}
<span id="followValue" style="font-size:70%;">{{ post.reply_set.count }} comment</span>
{% else %}
<span id="followValue" style="font-size:70%;">{{ post.reply_set.count }} comments</span>
{% endif %}
</div>
<!-- </div> -->
</div>
<div class="col-sm-5 col-md-3 col-lg-6" id="followBox" style="display:inline-block;">
<span id="followValue" style="font-size:70%;">{{ post.id|postlike_count }} vote(s)</span>
</div>
</div>
</div>
</div>
</ul>
</li>
<hr>
{% endfor %}
<hr>
{% endfor %}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion website/forum/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ <h3>Contacts</h3>
</dl>
<dl class="contact-list">
<dt>Phones:</dt>
<dd><i class="fas fa-phone-square"></i><a href="tel:+918420998766"> Ankit Maskara: +918420998766 </a>
<dd><i class="fas fa-phone-square"></i><a href="tel:+918240048380"> Prathamesh Mandiye: +918240048380 </a>
</dd>
</dl>
</div>
Expand Down
24 changes: 16 additions & 8 deletions website/import_scripts/import_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import csv
from random import choice
from string import ascii_uppercase
from website.utils import save_local_profile_pic_to_media


randhash = ''.join(choice(ascii_uppercase) for i in range(32))
Expand Down Expand Up @@ -35,18 +36,25 @@
u.profile.college = row['College']
u.profile.dept = row['Dept']
u.profile.email_confirmed=True
image_url = 'https://recursionnitd.in/'+'static/image/profile_pic/' + str(random.randint(1,15)) + '.png'
full_path = 'media/images/' + username + '.png'
#Development
#For development
# image_url = 'http://127.0.0.1:8000/'+'static/image/profile_pic/' + str(random.randint(1,15)) + '.png'
#Production: copy local static into MEDIA instead of fetching external URL
try:
urllib.request.urlretrieve(image_url, full_path)
except:
rel_media = save_local_profile_pic_to_media(username)
except Exception as e:
print("import_users: save_local_profile_pic_to_media exception:", repr(e))
rel_media = False

if not rel_media:
print("Downloadable Image Not Found!")
u.profile.image = '../' + full_path
else:
u.profile.image = rel_media # relative to MEDIA_ROOT
u.save()










Expand Down
6 changes: 5 additions & 1 deletion website/interview_exp/templates/exp_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@
<p>{{ experience.formatted_markdown | safe }}</p>
<p class="card-text">
<i>
<img src="{{ profile.image.url }}" width="5%" height="5%" style="border-radius: 30px; float: left;" alt="img">
{% if profile and profile.image %}
<img src="{{ profile.image.url }}" width="5%" height="5%" style="border-radius: 30px; float: left;" alt="img">
{% else %}
<img src="{% static 'image/profile_pic/default.png' %}" width="5%" height="5%" style="border-radius: 30px; float: left;" alt="default profile">
{% endif %}
<small class="mb-0" style="position:relative; top:15px;">
&nbsp
<a href="{% url 'user_profile:view_profile' experience.user.id %}">{{experience.user}}</a>
Expand Down
55 changes: 37 additions & 18 deletions website/interview_exp/templates/exp_list.html
Original file line number Diff line number Diff line change
@@ -1,32 +1,51 @@
{% load static %}

{% for experience in experiences %}
<div class="row mt-2 mb-2 ml-2 mr-2">
<div class="row mt-2 mb-2 ml-2 mr-2">
<div class="col-sm-2 col-lg-1">
{% for p in profile %}
{% if p.user == experience.user %}
<img src="{{ p.image.url }}" class="rounded-circle mt-2 mb-1"width="55px" height="55px" alt="img">
{% endif %}
{% if p.user == experience.user %}
{% if p.image %}
<img src="{{ p.image.url }}" class="rounded-circle mt-2 mb-1" width="55px" height="55px" alt="img">
{% else %}
<img src="{% static 'image/profile_pic/default.png' %}" class="rounded-circle mt-2 mb-1" width="55px" height="55px" alt="default">
{% endif %}
{% endif %}
{% endfor %}
</div>

<div class="col-lg-11 col-sm-9">
{% if experience.verification_Status == "Approved" %}
<a href="{% url 'interview_exp:detail_experiences' experience.id %}" style="color:#5277CF;"><strong>{{ experience.company }} Interview Experience {{ experience.year }}</strong> # {{ experience.id }}</a>
{% else %}
<a href="{% url 'interview_exp:detail_experiences' experience.id %}" style="color:rgb(207, 82, 99);"><strong>{{ experience.company }} Interview Experience {{ experience.year }}</strong> # {{ experience.id }}</a>
{% endif %}
{% if experience.verification_Status == "Approved" %}
<a href="{% url 'interview_exp:detail_experiences' experience.id %}" style="color:#5277CF;">
<strong>{{ experience.company }} Interview Experience {{ experience.year }}</strong> #{{ experience.id }}
</a>
{% else %}
<a href="{% url 'interview_exp:detail_experiences' experience.id %}" style="color:rgb(207, 82, 99);">
<strong>{{ experience.company }} Interview Experience {{ experience.year }}</strong> #{{ experience.id }}
</a>
{% endif %}

{% if request.user == experience.user %}
<div>
<!-- <a href="{% url 'interview_exp:update_experience' experience.id %}">Update</a> -->
</div>
<div>
<!-- Optionally add Update link here -->
</div>
{% endif %}

<ul>
<li><span style="color:#111111;">{{ experience.job_Profile }}</span> / <span style="color:#F95c39;">{{experience.role_Type}}</span></li>
<li>
<span style="color:#111111;">{{ experience.job_Profile }}</span> /
<span style="color:#F95c39;">{{ experience.role_Type }}</span>
</li>
<div class="row small">
<li class="col-sm-5 col-md-3 col-lg-4">Added by <a href="{% url 'user_profile:view_profile' experience.user.id %}">{{experience.user}}</a></li>
{% load staticfiles %}
<li class="col-sm-6 col-md-4 col-lg-4"><img src="{% static 'image/Datetime.png'%}" height='20px' width='20px'> {{ experience.updated_at }}</li>
<li class="col-sm-5 col-md-3 col-lg-4">
Added by <a href="{% url 'user_profile:view_profile' experience.user.id %}">{{ experience.user }}</a>
</li>
<li class="col-sm-6 col-md-4 col-lg-4">
<img src="{% static 'image/Datetime.png' %}" height="20px" width="20px"> {{ experience.updated_at }}
</li>
</div>
</ul>
</div>
</div>
<hr class="mt-0 mb-0">
{% endfor %}
<hr class="mt-0 mb-0">
{% endfor %}
6 changes: 6 additions & 0 deletions website/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions website/user_profile/templates/profile/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@
<div class="row">
<div class="col-lg-3 col-md-4 col-sm-12">
<div class="jumbotron container shadow-sm p-3 mb-1 bg-white rounded" style="background: white;">
{% if profile.image %}
<center><img src="{{ profile.image.url }}" alt="Profile Picture" height="100px" width="100px" style="border-radius: 100px;"></center>
{% endif %}
{% load static %}
<center>
{% if profile and profile.image %}
<img src="{{ profile.image.url }}" alt="Profile Picture" height="100px" width="100px" style="border-radius: 100px;">
{% else %}
<img src="{% static 'image/profile_pic/default.png' %}" alt="Profile Picture" height="100px" width="100px" style="border-radius: 100px;">
{% endif %}
</center>
<div style="text-align: center;">
<h3>{{ profile.name }}</h3>
<h5><small class="text-muted">@{{ profile.user }}</small></h5>
Expand Down
17 changes: 17 additions & 0 deletions website/user_profile/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,20 @@ def send_verification_mail(domain, user, *args, **kwargs):
threaded_mail.start()

return message


def valid_url_extension(url, allowed=('.jpg', '.jpeg', '.png', '.gif', '.webp')):
"""
Return True if the URL's path ends with an allowed image extension.
Keeps a lightweight check so views can safely attempt to download image files.
"""
try:
from urllib.parse import urlparse
path = urlparse(url).path or ''
path = path.lower()
for ext in allowed:
if path.endswith(ext):
return True
return False
except Exception:
return False
Loading