Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyasSarve committed Jul 19, 2022
0 parents commit e1baf91
Show file tree
Hide file tree
Showing 76 changed files with 3,073 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
db.sqlite3
Empty file added base/__init__.py
Empty file.
Binary file added base/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added base/__pycache__/admin.cpython-310.pyc
Binary file not shown.
Binary file added base/__pycache__/apps.cpython-310.pyc
Binary file not shown.
Binary file added base/__pycache__/forms.cpython-310.pyc
Binary file not shown.
Binary file added base/__pycache__/models.cpython-310.pyc
Binary file not shown.
Binary file added base/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file added base/__pycache__/views.cpython-310.pyc
Binary file not shown.
8 changes: 8 additions & 0 deletions base/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.contrib import admin

# Register your models here.
from .models import Room,Topic,Message

admin.site.register(Room)
admin.site.register(Topic)
admin.site.register(Message)
6 changes: 6 additions & 0 deletions base/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class BaseConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'base'
16 changes: 16 additions & 0 deletions base/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from django.forms import ModelForm
from .models import Room
from django.contrib.auth.models import User

class RoomForm(ModelForm):
class Meta:
model = Room
fields = '__all__'
exclude = ['host', 'participants']



class UserForm(ModelForm):
class Meta:
model = User
fields = ['username','email']
24 changes: 24 additions & 0 deletions base/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.0.6 on 2022-07-17 09:02

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Room',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200)),
('disciption', models.TextField(blank=True, null=True)),
('updated', models.DateTimeField(auto_now=True)),
('created', models.DateTimeField(auto_now_add=True)),
],
),
]
44 changes: 44 additions & 0 deletions base/migrations/0002_topic_room_user_message_room_topic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Generated by Django 4.0.6 on 2022-07-17 09:27

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('base', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='Topic',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200)),
],
),
migrations.AddField(
model_name='room',
name='user',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.CreateModel(
name='Message',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('body', models.TextField()),
('updated', models.DateTimeField(auto_now=True)),
('created', models.DateTimeField(auto_now_add=True)),
('room', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='base.room')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.AddField(
model_name='room',
name='topic',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='base.topic'),
),
]
18 changes: 18 additions & 0 deletions base/migrations/0003_rename_user_room_host.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.0.6 on 2022-07-17 10:31

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('base', '0002_topic_room_user_message_room_topic'),
]

operations = [
migrations.RenameField(
model_name='room',
old_name='user',
new_name='host',
),
]
24 changes: 24 additions & 0 deletions base/migrations/0004_alter_room_options_room_participants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.0.6 on 2022-07-17 17:38

from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('base', '0003_rename_user_room_host'),
]

operations = [
migrations.AlterModelOptions(
name='room',
options={'ordering': ['-updated', '-created']},
),
migrations.AddField(
model_name='room',
name='participants',
field=models.ManyToManyField(blank=True, related_name='participants', to=settings.AUTH_USER_MODEL),
),
]
Empty file added base/migrations/__init__.py
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added base/migrations/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
43 changes: 43 additions & 0 deletions base/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from pickle import TRUE
from pyexpat import model
from django.db import models
from django.contrib.auth.models import User
# Create your models here.


class Topic(models.Model):
name = models.CharField(max_length=200)

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


class Room(models.Model):
host = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
topic = models.ForeignKey(Topic, on_delete=models.SET_NULL, null=True)
name = models.CharField(max_length=200)
disciption = models.TextField(null=True, blank=True)
participants = models.ManyToManyField(
User, related_name='participants', blank=True)
updated = models.DateTimeField(auto_now=True)
created = models.DateTimeField(auto_now_add=True)

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

class Meta:
ordering = ["-updated", "-created"]


class Message(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
room = models.ForeignKey(Room, on_delete=models.CASCADE)
body = models.TextField()
updated = models.DateTimeField(auto_now=True)
created = models.DateTimeField(auto_now_add=True)

class Meta:
ordering = ["-updated", "-created"]

def __str__(self) -> str:
return self.body[0:50]
56 changes: 56 additions & 0 deletions base/templates/base/activity_component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<div class="activities">
<div class="activities__header">
<h2>Recent Activities</h2>
</div>
{% for message in messages %}
<div class="activities__box">
<div class="activities__boxHeader roomListRoom__header">
<a href="{% url 'userprofile' message.user.id %}" class="roomListRoom__author">
<div class="avatar avatar--small">
<img src="https://randomuser.me/api/portraits/women/11.jpg" />
</div>
<p>
@{{message.user}}
<span>{{message.created|timesince}}</span>
</p>
</a>
{% if request.user == message.user %}
<div class="roomListRoom__actions">
<a href="{% url 'deletemessage' message.id %}">
<svg
version="1.1"
xmlns="http://www.w3.org/2000/svg"
width="32"
height="32"
viewBox="0 0 32 32"
>
<title>remove</title>
<path
d="M27.314 6.019l-1.333-1.333-9.98 9.981-9.981-9.981-1.333 1.333 9.981 9.981-9.981 9.98 1.333 1.333 9.981-9.98 9.98 9.98 1.333-1.333-9.98-9.98 9.98-9.981z"
></path>
</svg>
</a>
</div>
{% endif %}
</div>
<div class="activities__boxContent">
<p>
replied to post “<a href="{% url "room" message.room.id %}">{{message.room}}</a
>
</p>
<div class="activities__boxRoomContent">
{{message.body}}
</div>
</div>
</div>
{% endfor %}
</div>









39 changes: 39 additions & 0 deletions base/templates/base/delete.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{% extends 'main.html' %} {% block content %}
<main class="delete-item layout">
<div class="container">
<div class="layout__box">
<div class="layout__boxHeader">
<div class="layout__boxTitle">
<a href={{request.META.HTTP_REFERER}}>
<svg
version="1.1"
xmlns="http://www.w3.org/2000/svg"
width="32"
height="32"
viewBox="0 0 32 32"
>
<title>arrow-left</title>
<path
d="M13.723 2.286l-13.723 13.714 13.719 13.714 1.616-1.611-10.96-10.96h27.625v-2.286h-27.625l10.965-10.965-1.616-1.607z"
></path>
</svg>
</a>
<h3>Back</h3>
</div>
</div>
<div class="layout__body">
<form class="form" action="#">
{% csrf_token %}
<div class="form__group">
<p>Are you sure you want to delete "{{obj}}"?</p>
</div>

<div class="for__group">
<input class="btn btn--main" type="submit" value="Confirm" />
</div>
</form>
</div>
</div>
</div>
</main>
{% endblock content %}
10 changes: 10 additions & 0 deletions base/templates/base/delete_old.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% extends 'main.html' %}

{% block content %}
<form action="" method="POST">
{% csrf_token %}
<p>Are you sure you want to delete "{{obj}}?"</p>
<a href="{{request.META.HTTP_REFERER}}">Go Back</a>
<input type="Submit" value="Confirm"/>
</form>
{% endblock content %}
65 changes: 65 additions & 0 deletions base/templates/base/feed_component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

{% for room in rooms%}

<div class="roomListRoom">
<div class="roomListRoom__header">
<a href="{% url 'userprofile' room.host.id %}" class="roomListRoom__author">
<div class="avatar avatar--small active">
<img src="https://randomuser.me/api/portraits/men/11.jpg" />
</div>
<span>@{{room.host.username}}</span>
</a>
<div class="roomListRoom__actions">
<span>{{room.created|timesince}}</span>
</div>
</div>
<div class="roomListRoom__content">
<a href="{% url 'room' room.id%}">{{room.name}}</a>
<p>
{{room.discription}}
</p>
</div>
<div class="roomListRoom__meta">
<a class="roomListRoom__joined">
<svg
version="1.1"
xmlns="http://www.w3.org/2000/svg"
width="32"
height="32"
viewBox="0 0 32 32"
>
<title>user-group</title>
<path
d="M30.539 20.766c-2.69-1.547-5.75-2.427-8.92-2.662 0.649 0.291 1.303 0.575 1.918 0.928 0.715 0.412 1.288 1.005 1.71 1.694 1.507 0.419 2.956 1.003 4.298 1.774 0.281 0.162 0.456 0.487 0.456 0.85v4.65h-4v2h5c0.553 0 1-0.447 1-1v-5.65c0-1.077-0.56-2.067-1.461-2.584z"
></path>
<path
d="M22.539 20.766c-6.295-3.619-14.783-3.619-21.078 0-0.901 0.519-1.461 1.508-1.461 2.584v5.65c0 0.553 0.447 1 1 1h22c0.553 0 1-0.447 1-1v-5.651c0-1.075-0.56-2.064-1.461-2.583zM22 28h-20v-4.65c0-0.362 0.175-0.688 0.457-0.85 5.691-3.271 13.394-3.271 19.086 0 0.282 0.162 0.457 0.487 0.457 0.849v4.651z"
></path>
<path
d="M19.502 4.047c0.166-0.017 0.33-0.047 0.498-0.047 2.757 0 5 2.243 5 5s-2.243 5-5 5c-0.168 0-0.332-0.030-0.498-0.047-0.424 0.641-0.944 1.204-1.513 1.716 0.651 0.201 1.323 0.331 2.011 0.331 3.859 0 7-3.141 7-7s-3.141-7-7-7c-0.688 0-1.36 0.131-2.011 0.331 0.57 0.512 1.089 1.075 1.513 1.716z"
></path>
<path
d="M12 16c3.859 0 7-3.141 7-7s-3.141-7-7-7c-3.859 0-7 3.141-7 7s3.141 7 7 7zM12 4c2.757 0 5 2.243 5 5s-2.243 5-5 5-5-2.243-5-5c0-2.757 2.243-5 5-5z"
></path>
</svg>
{{room.participants.all.count}} Joined
</a>
<p class="roomListRoom__topic">{{room.topic}}</p>
</div>
</div>
{% endfor%}










{% comment %} <div class="my-3 mx-5">
<a href=>@{{room.host.username}}</a>
<h5><a href="{% url 'room' room.id %}">{{room.name}}</a></h5>
</div>
<hr /> {% endcomment %}
Loading

0 comments on commit e1baf91

Please sign in to comment.