Compare commits
No commits in common. "3b407f393d5598646d1829c7dfc074bc4ca40a8a" and "1e2e32e0267e2749ba6bf61c73b7060f9a1463dc" have entirely different histories.
3b407f393d
...
1e2e32e026
17 changed files with 43 additions and 193 deletions
|
|
@ -35,7 +35,6 @@ INSTALLED_APPS = [
|
||||||
"django.contrib.sessions",
|
"django.contrib.sessions",
|
||||||
"django.contrib.messages",
|
"django.contrib.messages",
|
||||||
"django.contrib.staticfiles",
|
"django.contrib.staticfiles",
|
||||||
"django_bootstrap5",
|
|
||||||
"flangr.posts",
|
"flangr.posts",
|
||||||
"flangr.circles",
|
"flangr.circles",
|
||||||
]
|
]
|
||||||
|
|
@ -115,5 +114,3 @@ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
||||||
MEDIA_URL = "media/"
|
MEDIA_URL = "media/"
|
||||||
|
|
||||||
AUTH_USER_MODEL = "auth.User"
|
AUTH_USER_MODEL = "auth.User"
|
||||||
|
|
||||||
STATICFILES_DIRS = ["flangr/static"]
|
|
||||||
|
|
|
||||||
|
|
@ -6,5 +6,5 @@ app_name = "circles"
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", views.CircleListView.as_view(), name="circle_list"),
|
path("", views.CircleListView.as_view(), name="circle_list"),
|
||||||
path("circle/<int:pk>", views.CircleUpdateView.as_view(), name="circle_update"),
|
path("circle/<int:pk>", views.CircleUpdateView.as_view(), name="circle_update"),
|
||||||
path("circle/new", views.CircleCreateView.as_view(), name="circle_create"),
|
path("add", views.CircleCreateView.as_view(), name="circle_create"),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@ class CircleCreateView(LoginRequiredMixin, CreateView):
|
||||||
circle = form.save(commit=False)
|
circle = form.save(commit=False)
|
||||||
circle.owner = self.request.user
|
circle.owner = self.request.user
|
||||||
circle.save()
|
circle.save()
|
||||||
form.save_m2m()
|
|
||||||
|
|
||||||
return HttpResponseRedirect(self.get_success_url())
|
return HttpResponseRedirect(self.get_success_url())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,5 @@ from . import views
|
||||||
app_name = "posts"
|
app_name = "posts"
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("post/<int:pk>", views.PostDetailView.as_view(), name="post_detail"),
|
path("post/<int:pk>", views.PostDetailView.as_view(), name="post_detail"),
|
||||||
path(
|
|
||||||
"post/<int:pk>/fullscreen",
|
|
||||||
views.PostDetailView.as_view(template_name_suffix="_fullscreen"),
|
|
||||||
name="post_fullscreen",
|
|
||||||
),
|
|
||||||
path("post/new", views.PostCreateView.as_view(), name="post_create"),
|
path("post/new", views.PostCreateView.as_view(), name="post_create"),
|
||||||
path("posts", views.PostListView.as_view(), name="post_list"),
|
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ from django.http import HttpResponseRedirect
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.views.generic import CreateView
|
from django.views.generic import CreateView
|
||||||
from django.views.generic import DetailView
|
from django.views.generic import DetailView
|
||||||
from django.views.generic import ListView
|
|
||||||
from django.views.generic.edit import ModelFormMixin
|
from django.views.generic.edit import ModelFormMixin
|
||||||
|
|
||||||
from .models import Comment
|
from .models import Comment
|
||||||
|
|
@ -49,11 +48,5 @@ class PostCreateView(LoginRequiredMixin, CreateView):
|
||||||
self.object = form.save(commit=False)
|
self.object = form.save(commit=False)
|
||||||
self.object.user = self.request.user
|
self.object.user = self.request.user
|
||||||
self.object.save()
|
self.object.save()
|
||||||
form.save_m2m()
|
|
||||||
|
|
||||||
return HttpResponseRedirect(self.get_success_url())
|
return HttpResponseRedirect(self.get_success_url())
|
||||||
|
|
||||||
|
|
||||||
class PostListView(LoginRequiredMixin, ListView):
|
|
||||||
def get_queryset(self):
|
|
||||||
return Post.objects.filter(circles__members=self.request.user)
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
.img-full {
|
|
||||||
object-fit: contain;
|
|
||||||
}
|
|
||||||
|
|
@ -1,49 +1,6 @@
|
||||||
{% load django_bootstrap5 %}
|
|
||||||
{% load static %}
|
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Flangr</title>
|
<title>Flangr</title>
|
||||||
<link rel="stylesheet" href="{% static 'css/base.css' %}">
|
|
||||||
{% bootstrap_css %}
|
|
||||||
{% block extracss %}{% endblock extracss %}
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>{% block content %}{% endblock content %}</body>
|
||||||
{% block nav %}
|
|
||||||
<nav class="navbar navbar-expand-md navbar-light bg-light mb-2">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="/">Flangr</a>
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="collapse navbar-collapse" id="navbarNav">
|
|
||||||
<ul class="navbar-nav me-auto">
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="{% url 'posts:post_list' %}">Posts</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="{% url 'circles:circle_list' %}">Circles</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<ul class="navbar-nav">
|
|
||||||
{% if user %}
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">{{ user.username }}</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="{% url 'logout' %}">Logout</a>
|
|
||||||
</li>
|
|
||||||
{% else %}
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="{% url 'login' %}">Login</a>
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{% endblock nav %}
|
|
||||||
{% bootstrap_messages %}
|
|
||||||
{% block content %}{% endblock content %}
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,9 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% load django_bootstrap5 %}
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="container">
|
<h1>Circle {{ object.name }}</h1>
|
||||||
<div class="row">
|
<form action="#" method="post">
|
||||||
<div class="col">
|
|
||||||
<h1>Create a new circle</h1>
|
|
||||||
<form action="" method="post">
|
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% bootstrap_form form %}
|
{{ form }}
|
||||||
{% bootstrap_button button_type="submit" content="OK" %}
|
<input type="submit" value="Post">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,9 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col">
|
|
||||||
<h1>Your Circles</h1>
|
<h1>Your Circles</h1>
|
||||||
<table class="table">
|
<ul>
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Members</th>
|
|
||||||
</tr>
|
|
||||||
{% for circle in object_list %}
|
{% for circle in object_list %}
|
||||||
<tr>
|
<li><a href="{% url "circles:circle_update" circle.pk %}">{{ circle.name }}</a></li>
|
||||||
<td><a href="{% url "circles:circle_update" circle.pk %}">{{ circle.name }}</a></td>
|
|
||||||
<td>{{ circle.members.all }}</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</ul>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,11 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% load django_bootstrap5 %}
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-8">
|
|
||||||
{% if object.title %}
|
{% if object.title %}
|
||||||
<h1>{{ object.title }}</h1>
|
<h1>{{ object.title }}</h1>
|
||||||
{% else %}
|
{% else %}
|
||||||
<h1>{{ object.user.username }}</h1>
|
<h1>{{ object.user.username }}</h1>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a href="{% url 'posts:post_fullscreen' object.pk %}"><img class="img-fluid" src={{ object.img.url }}/></a>
|
<img width=400 src={{ object.img.url }}/>
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<h2> Comments</h2>
|
<h2> Comments</h2>
|
||||||
<ul>
|
<ul>
|
||||||
{% for comment in object.comments.all %}
|
{% for comment in object.comments.all %}
|
||||||
|
|
@ -21,10 +14,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% bootstrap_form form %}
|
{{ form }}
|
||||||
{% bootstrap_button button_type="submit" content="OK" %}
|
<input type="submit", value="Post">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,10 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% load django_bootstrap5 %}
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col">
|
|
||||||
<h1>Upload a new picture</h1>
|
<h1>Upload a new picture</h1>
|
||||||
<form enctype="multipart/form-data" action="" method="post">
|
<form enctype="multipart/form-data" action="" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% bootstrap_form form %}
|
{{ form }}
|
||||||
{% bootstrap_button button_type="submit" content="OK" %}
|
|
||||||
<input type="submit" value="Post">
|
<input type="submit" value="Post">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
{% extends "base.html" %}
|
|
||||||
{% load django_bootstrap5 %}
|
|
||||||
|
|
||||||
{% block nav %}{% endblock nav %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<div class="vh-100 bg-dark d-flex flex-column">
|
|
||||||
<div class="d-flex flex-row m-2 justify-content-between align-items-center">
|
|
||||||
<h3 class="text-light">{{ object.title }}</h1>
|
|
||||||
<a class="btn btn-dark" href="{% url 'posts:post_detail' object.pk %}">X</a>
|
|
||||||
</div>
|
|
||||||
<div class="flex-fill flex-shrink-1">
|
|
||||||
<img class="img-full w-100 h-100" src={{ object.img.url }}/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock content %}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
{% extends "base.html" %}
|
|
||||||
{% block content %}
|
|
||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col">
|
|
||||||
<h1>Posts Shared with you</h1>
|
|
||||||
<ul>
|
|
||||||
{% for post in object_list %}
|
|
||||||
<li><a href="{% url "posts:post_detail" post.pk %}">{{ post.title }}</a></li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock content %}
|
|
||||||
|
|
@ -1,19 +1,10 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% load django_bootstrap5 %}
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col">
|
|
||||||
<h1>Login</h1>
|
<h1>Login</h1>
|
||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% bootstrap_form form %}
|
{{ form }}
|
||||||
{% bootstrap_button button_type="submit" content="OK" %}
|
<input type="submit", value="Post">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
|
||||||
|
|
@ -16,20 +16,15 @@ Including another URLconf
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.conf.urls.static import static
|
from django.conf.urls.static import static
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
|
||||||
from django.urls import include
|
from django.urls import include
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from .posts.views import PostListView
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("admin/", admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
path("accounts/", include("django.contrib.auth.urls")),
|
path("accounts/", include("django.contrib.auth.urls")),
|
||||||
path("posts/", include("flangr.posts.urls")),
|
path("posts/", include("flangr.posts.urls")),
|
||||||
path("circles/", include("flangr.circles.urls")),
|
path("circles/", include("flangr.circles.urls")),
|
||||||
path("", PostListView.as_view(), name="home"),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
urlpatterns += staticfiles_urlpatterns()
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
pillow
|
pillow
|
||||||
django
|
django
|
||||||
coverage
|
coverage
|
||||||
django-bootstrap5
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,2 @@
|
||||||
-r base.txt
|
|
||||||
pre-commit
|
pre-commit
|
||||||
flake8
|
flake8
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue