-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interactive Tweet Management System #877
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
env/ |
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,4 @@ | ||
asgiref==3.8.1 | ||
Django==5.1.2 | ||
sqlparse==0.5.1 | ||
tzdata==2024.2 |
Binary file not shown.
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,22 @@ | ||
#!/usr/bin/env python | ||
"""Django's command-line utility for administrative tasks.""" | ||
import os | ||
import sys | ||
|
||
|
||
def main(): | ||
"""Run administrative tasks.""" | ||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tweethead.settings') | ||
try: | ||
from django.core.management import execute_from_command_line | ||
except ImportError as exc: | ||
raise ImportError( | ||
"Couldn't import Django. Are you sure it's installed and " | ||
"available on your PYTHONPATH environment variable? Did you " | ||
"forget to activate a virtual environment?" | ||
) from exc | ||
execute_from_command_line(sys.argv) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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,5 @@ | ||
asgiref==3.8.1 | ||
Django==5.1.2 | ||
pillow==11.0.0 | ||
sqlparse==0.5.1 | ||
tzdata==2024.2 |
83 changes: 83 additions & 0 deletions
83
Web_Development/djangotweet/tweethead/templates/layout.html
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,83 @@ | ||
{% load static %} | ||
|
||
<!DOCTYPE html> | ||
<html lang="en" data-bs-theme="dark"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> | ||
|
||
</head> | ||
<title> | ||
{% block title %} | ||
|
||
Chai and django | ||
|
||
{% endblock %} | ||
|
||
|
||
</title> | ||
</head> | ||
<body> | ||
<nav class="navbar navbar-expand-lg bg-body-tertiary"> | ||
<div class="container-fluid"> | ||
<a class="navbar-brand" href="#">Tweet bar</a> | ||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> | ||
<span class="navbar-toggler-icon"></span> | ||
</button> | ||
<div class="collapse navbar-collapse" id="navbarSupportedContent"> | ||
<ul class="navbar-nav me-auto mb-2 mb-lg-0"> | ||
<li class="nav-item"> | ||
<a class="nav-link active" aria-current="page" href="#">Home</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="#">Link</a> | ||
</li> | ||
<li class="nav-item dropdown"> | ||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"> | ||
Dropdown | ||
</a> | ||
<ul class="dropdown-menu"> | ||
<li><a class="dropdown-item" href="#">Action</a></li> | ||
<li><a class="dropdown-item" href="#">Another action</a></li> | ||
<li><hr class="dropdown-divider"></li> | ||
<li><a class="dropdown-item" href="#">Something else here</a></li> | ||
</ul> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link disabled" aria-disabled="true">Disabled</a> | ||
</li> | ||
</ul> | ||
<form class="d-flex" role="search"> | ||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search"> | ||
<button class="btn btn-outline-success" type="submit">Search</button> | ||
</form> | ||
|
||
<a href="{% url 'tweet_list' %}" class="btn btn-primary mx-2">Tweet Home</a> | ||
{% if user.is_authenticated %} | ||
<form method="post" action="{% url 'logout' %}"> | ||
{% csrf_token %} | ||
<button class="btn btn-danger" type="submit">Logout</button> | ||
</form> | ||
{% else %} | ||
<a href="{% url 'register' %}" class="btn btn-primary mx-2">Register</a> | ||
<a href="{% url 'login' %}" class="btn btn-outline-success mx-2">Login</a> | ||
{% endif %} | ||
</div> | ||
</div> | ||
</nav> | ||
|
||
|
||
|
||
|
||
<div class="container"> | ||
{% block container %} | ||
|
||
|
||
{% endblock %} | ||
|
||
|
||
</div> | ||
|
||
</body> | ||
</html> |
7 changes: 7 additions & 0 deletions
7
Web_Development/djangotweet/tweethead/templates/registration/logged_out.html
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,7 @@ | ||
{% extends "layout.html" %} | ||
|
||
{% block container %} | ||
<h2>Logged out</h2> | ||
|
||
<p>You have been logged out<a href="{% url 'login' %}">Login here</a></p> | ||
{% endblock %} |
11 changes: 11 additions & 0 deletions
11
Web_Development/djangotweet/tweethead/templates/registration/login.html
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,11 @@ | ||
{% extends "layout.html" %} | ||
|
||
{% block container %} | ||
<h2>Login form</h2> | ||
<form method="post"> | ||
{% csrf_token %} | ||
{{ form.as_p }} | ||
<button class="btn btn-primary">Login</button> | ||
</form> | ||
<p>Don't have an account? <a href="{% url 'register' %}">Register here</a></p> | ||
{% endblock %} |
11 changes: 11 additions & 0 deletions
11
Web_Development/djangotweet/tweethead/templates/registration/register.html
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,11 @@ | ||
{% extends "layout.html" %} | ||
|
||
{% block container %} | ||
<h2>Register form form</h2> | ||
<form method="post"> | ||
{% csrf_token %} | ||
{{ form.as_p }} | ||
<button class="btn btn-primary">Register</button> | ||
</form> | ||
|
||
{% endblock %} |
Empty file.
Binary file added
BIN
+158 Bytes
Web_Development/djangotweet/tweethead/tweet/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file added
BIN
+349 Bytes
Web_Development/djangotweet/tweethead/tweet/__pycache__/admin.cpython-312.pyc
Binary file not shown.
Binary file added
BIN
+477 Bytes
Web_Development/djangotweet/tweethead/tweet/__pycache__/apps.cpython-312.pyc
Binary file not shown.
Binary file added
BIN
+1.25 KB
Web_Development/djangotweet/tweethead/tweet/__pycache__/forms.cpython-312.pyc
Binary file not shown.
Binary file added
BIN
+1.23 KB
Web_Development/djangotweet/tweethead/tweet/__pycache__/models.cpython-312.pyc
Binary file not shown.
Binary file added
BIN
+730 Bytes
Web_Development/djangotweet/tweethead/tweet/__pycache__/urls.cpython-312.pyc
Binary file not shown.
Binary file added
BIN
+3.62 KB
Web_Development/djangotweet/tweethead/tweet/__pycache__/views.cpython-312.pyc
Binary file not shown.
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,6 @@ | ||
from django.contrib import admin | ||
from .models import Tweet | ||
|
||
# Register your models here. | ||
|
||
admin.site.register(Tweet) |
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,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class TweetConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'tweet' |
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,16 @@ | ||
from django import forms | ||
from .models import Tweet | ||
from django.contrib.auth.forms import UserCreationForm | ||
from django.contrib.auth.models import User | ||
|
||
class TweetForm(forms.ModelForm): | ||
class Meta: | ||
model = Tweet | ||
fields = ['text','photo'] | ||
|
||
|
||
class UserRegistrationForm(UserCreationForm): | ||
email=forms.EmailField() | ||
class Meta: | ||
model = User | ||
fields = ('username','email','password1','password2') |
28 changes: 28 additions & 0 deletions
28
Web_Development/djangotweet/tweethead/tweet/migrations/0001_initial.py
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,28 @@ | ||
# Generated by Django 5.1.2 on 2024-10-17 06:04 | ||
|
||
import django.db.models.deletion | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Tweet', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('text', models.TextField(max_length=240)), | ||
('photo', models.ImageField(blank=True, null=True, upload_to='photos/')), | ||
('created_at', models.DateField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
], | ||
), | ||
] |
Empty file.
Binary file added
BIN
+1.63 KB
...velopment/djangotweet/tweethead/tweet/migrations/__pycache__/0001_initial.cpython-312.pyc
Binary file not shown.
Binary file added
BIN
+169 Bytes
Web_Development/djangotweet/tweethead/tweet/migrations/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
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,23 @@ | ||
from django.db import models | ||
from django.contrib.auth.models import User | ||
|
||
# Create your models here. | ||
|
||
|
||
class Tweet(models.Model): | ||
|
||
user=models.ForeignKey(User,on_delete=models.CASCADE) | ||
text=models.TextField(max_length=240) | ||
photo=models.ImageField(upload_to = 'photos/', blank=True, null=True) | ||
created_at=models.DateField(auto_now_add=True) | ||
updated_at=models.DateTimeField(auto_now=True) | ||
|
||
|
||
def __str__(self): | ||
return f'{self.user.username} - {self.text[:10]}' | ||
|
||
|
||
|
||
|
||
|
||
|
17 changes: 17 additions & 0 deletions
17
Web_Development/djangotweet/tweethead/tweet/templates/index.html
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,17 @@ | ||
{% extends "layout.html" %} | ||
|
||
{% block title %} | ||
|
||
|
||
Chai aur tweet | ||
|
||
{% endblock %} | ||
|
||
{% block container %} | ||
|
||
|
||
<h1 class="text-center mt-4"> | ||
Welcome to this django project | ||
|
||
</h1> | ||
{% endblock %} |
26 changes: 26 additions & 0 deletions
26
Web_Development/djangotweet/tweethead/tweet/templates/tweet_confirm_delete.html
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,26 @@ | ||
{% extends "layout.html" %} | ||
|
||
{% block title %} | ||
|
||
|
||
Chai aur tweet | ||
|
||
{% endblock %} | ||
|
||
{% block container %} | ||
|
||
|
||
<h1 class="text-center mt-4"> | ||
Are you sure you want to delete this tweet? | ||
|
||
</h1> | ||
|
||
<form method="post"> | ||
{% csrf_token %} | ||
<button class="btn btn-danger">Delete</button> | ||
<a class="btn btn-success" href="{% url 'tweet_list' %}">Cancel</a> | ||
</form> | ||
|
||
|
||
|
||
{% endblock %} |
27 changes: 27 additions & 0 deletions
27
Web_Development/djangotweet/tweethead/tweet/templates/tweet_form.html
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,27 @@ | ||
{% extends "layout.html" %} | ||
|
||
{% block title %} | ||
Chai aur tweet | ||
{% endblock %} | ||
|
||
{% block container %} | ||
<h1 class="text-center mt-4"> | ||
Welcome to this Django project | ||
</h1> | ||
|
||
<h2> | ||
{% if form.instance.pk %} | ||
Edit Tweet | ||
{% else %} | ||
Create Tweet | ||
{% endif %} | ||
</h2> | ||
|
||
<form method="post" enctype="multipart/form-data" class="form"> | ||
{% csrf_token %} | ||
{{ form.as_p }} | ||
<button class="btn btn-warning" type="submit">Submit</button> | ||
</form> | ||
|
||
<a href="{% url 'tweet_list' %}">Back to tweet list</a> | ||
{% endblock %} |
40 changes: 40 additions & 0 deletions
40
Web_Development/djangotweet/tweethead/tweet/templates/tweet_list.html
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,40 @@ | ||
{% extends "layout.html" %} | ||
|
||
{% block title %} | ||
|
||
|
||
Chai aur tweet | ||
|
||
{% endblock %} | ||
|
||
{% block container %} | ||
|
||
|
||
<h1 class="text-center mt-4"> | ||
Welcome to this django project | ||
</h1> | ||
|
||
<a class="btn btn-primary" href="{% url 'tweet_create' %}">Create a tweet</a> | ||
|
||
<div class="container row gap-3"> | ||
{%for tweet in tweets%} | ||
<div class="card" style="width: 18rem;"> | ||
<img src="{{tweet.photo.url}}" class="card-img-top" alt="..."> | ||
<div class="card-body"> | ||
<h5 class="card-title">{{tweet.user.username}}</h5> | ||
<p class="card-text">{{tweet.text}}</p> | ||
|
||
{% if tweet.user == user %} | ||
<a href="{% url 'tweet_edit' tweet.id %}" class="btn btn-primary">Edit</a> | ||
<a href="{% url 'tweet_delete' tweet.id %}" class="btn btn-danger">Delete</a> | ||
{% endif %} | ||
</div> | ||
</div> | ||
|
||
{% endfor %} | ||
|
||
|
||
</div> | ||
|
||
|
||
{% endblock %} |
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,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
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,14 @@ | ||
|
||
from django.urls import path | ||
from . import views | ||
|
||
|
||
urlpatterns = [ | ||
|
||
|
||
path('',views.tweet_list,name='tweet_list'), | ||
path('create/',views.tweet_create,name='tweet_create'), | ||
path('<int:tweet_id>/edit/',views.tweet_edit,name='tweet_edit'), | ||
path('<int:tweet_id>/delete/',views.tweet_delete,name='tweet_delete'), | ||
path('register/',views.register,name='register'), | ||
] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Ananyashetty7 ,
Please remove the BINARY files like .pyc.
Also try adding a README.md file to this , helps understand the structure of the project.
Update the changes and I will approve the PR.
Also if you need any help let me know!
Thank you!