diff --git a/config/settings/base.py b/config/settings/base.py index c713143..764ac2e 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -35,6 +35,7 @@ INSTALLED_APPS = [ "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", + "django_bootstrap5", "flangr.posts", "flangr.circles", ] @@ -114,3 +115,5 @@ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" MEDIA_URL = "media/" AUTH_USER_MODEL = "auth.User" + +STATICFILES_DIRS = ["flangr/static"] diff --git a/flangr/circles/urls.py b/flangr/circles/urls.py index 54d0d59..d911ce4 100644 --- a/flangr/circles/urls.py +++ b/flangr/circles/urls.py @@ -6,5 +6,5 @@ app_name = "circles" urlpatterns = [ path("", views.CircleListView.as_view(), name="circle_list"), path("circle/", views.CircleUpdateView.as_view(), name="circle_update"), - path("add", views.CircleCreateView.as_view(), name="circle_create"), + path("circle/new", views.CircleCreateView.as_view(), name="circle_create"), ] diff --git a/flangr/circles/views.py b/flangr/circles/views.py index 590f5ed..3a77d30 100644 --- a/flangr/circles/views.py +++ b/flangr/circles/views.py @@ -34,6 +34,7 @@ class CircleCreateView(LoginRequiredMixin, CreateView): circle = form.save(commit=False) circle.owner = self.request.user circle.save() + form.save_m2m() return HttpResponseRedirect(self.get_success_url()) diff --git a/flangr/posts/urls.py b/flangr/posts/urls.py index 7dc96a0..fe472ee 100644 --- a/flangr/posts/urls.py +++ b/flangr/posts/urls.py @@ -5,5 +5,11 @@ from . import views app_name = "posts" urlpatterns = [ path("post/", views.PostDetailView.as_view(), name="post_detail"), + path( + "post//fullscreen", + views.PostDetailView.as_view(template_name_suffix="_fullscreen"), + name="post_fullscreen", + ), path("post/new", views.PostCreateView.as_view(), name="post_create"), + path("posts", views.PostListView.as_view(), name="post_list"), ] diff --git a/flangr/posts/views.py b/flangr/posts/views.py index f3685e3..ffbd1ba 100644 --- a/flangr/posts/views.py +++ b/flangr/posts/views.py @@ -4,6 +4,7 @@ from django.http import HttpResponseRedirect from django.urls import reverse from django.views.generic import CreateView from django.views.generic import DetailView +from django.views.generic import ListView from django.views.generic.edit import ModelFormMixin from .models import Comment @@ -48,5 +49,11 @@ class PostCreateView(LoginRequiredMixin, CreateView): self.object = form.save(commit=False) self.object.user = self.request.user self.object.save() + form.save_m2m() return HttpResponseRedirect(self.get_success_url()) + + +class PostListView(LoginRequiredMixin, ListView): + def get_queryset(self): + return Post.objects.filter(circles__members=self.request.user) diff --git a/flangr/static/css/base.css b/flangr/static/css/base.css new file mode 100644 index 0000000..c37ca54 --- /dev/null +++ b/flangr/static/css/base.css @@ -0,0 +1,3 @@ +.img-full { + object-fit: contain; +} diff --git a/flangr/templates/base.html b/flangr/templates/base.html index 0f1d64b..302257b 100644 --- a/flangr/templates/base.html +++ b/flangr/templates/base.html @@ -1,6 +1,49 @@ +{% load django_bootstrap5 %} +{% load static %} + Flangr + + {% bootstrap_css %} + {% block extracss %}{% endblock extracss %} - {% block content %}{% endblock content %} + + {% block nav %} + + {% endblock nav %} + {% bootstrap_messages %} + {% block content %}{% endblock content %} + diff --git a/flangr/templates/circles/circle_form.html b/flangr/templates/circles/circle_form.html index 1ccb008..622f6ac 100644 --- a/flangr/templates/circles/circle_form.html +++ b/flangr/templates/circles/circle_form.html @@ -1,9 +1,17 @@ {% extends "base.html" %} +{% load django_bootstrap5 %} + {% block content %} -

Circle {{ object.name }}

-
- {% csrf_token %} - {{ form }} - -
+
+
+
+

Create a new circle

+
+ {% csrf_token %} + {% bootstrap_form form %} + {% bootstrap_button button_type="submit" content="OK" %} +
+
+
+
{% endblock content %} diff --git a/flangr/templates/circles/circle_list.html b/flangr/templates/circles/circle_list.html index e608e86..899e1ca 100644 --- a/flangr/templates/circles/circle_list.html +++ b/flangr/templates/circles/circle_list.html @@ -1,9 +1,22 @@ {% extends "base.html" %} {% block content %} -

Your Circles

- +
+
+
+

Your Circles

+ + + + + + {% for circle in object_list %} + + + + + {% endfor %} +
NameMembers
{{ circle.name }}{{ circle.members.all }}
+
+
+
{% endblock content %} diff --git a/flangr/templates/posts/post_detail.html b/flangr/templates/posts/post_detail.html index 57d573c..726e5c2 100644 --- a/flangr/templates/posts/post_detail.html +++ b/flangr/templates/posts/post_detail.html @@ -1,20 +1,30 @@ {% extends "base.html" %} +{% load django_bootstrap5 %} + {% block content %} - {% if object.title %} -

{{ object.title }}

- {% else %} -

{{ object.user.username }}

- {% endif %} - -

Comments

-
    - {% for comment in object.comments.all %} -
  • {{ comment.user }} - {{ comment.comment }}
  • - {% endfor %} -
-
- {% csrf_token %} - {{ form }} - -
+
+
+
+ {% if object.title %} +

{{ object.title }}

+ {% else %} +

{{ object.user.username }}

+ {% endif %} + +
+
+

Comments

+
    + {% for comment in object.comments.all %} +
  • {{ comment.user }} - {{ comment.comment }}
  • + {% endfor %} +
+
+ {% csrf_token %} + {% bootstrap_form form %} + {% bootstrap_button button_type="submit" content="OK" %} +
+
+
+
{% endblock content %} diff --git a/flangr/templates/posts/post_form.html b/flangr/templates/posts/post_form.html index 66bfaba..09ae82c 100644 --- a/flangr/templates/posts/post_form.html +++ b/flangr/templates/posts/post_form.html @@ -1,10 +1,19 @@ {% extends "base.html" %} +{% load django_bootstrap5 %} {% block content %} -

Upload a new picture

-
- {% csrf_token %} - {{ form }} - -
+
+
+
+

Upload a new picture

+
+ {% csrf_token %} + {% bootstrap_form form %} + {% bootstrap_button button_type="submit" content="OK" %} + +
+
+
+
+ {% endblock content %} diff --git a/flangr/templates/posts/post_fullscreen.html b/flangr/templates/posts/post_fullscreen.html new file mode 100644 index 0000000..9200f39 --- /dev/null +++ b/flangr/templates/posts/post_fullscreen.html @@ -0,0 +1,16 @@ +{% extends "base.html" %} +{% load django_bootstrap5 %} + +{% block nav %}{% endblock nav %} + +{% block content %} +
+
+

{{ object.title }}

+ X +
+
+ +
+
+{% endblock content %} diff --git a/flangr/templates/posts/post_list.html b/flangr/templates/posts/post_list.html new file mode 100644 index 0000000..5bc3c66 --- /dev/null +++ b/flangr/templates/posts/post_list.html @@ -0,0 +1,15 @@ +{% extends "base.html" %} +{% block content %} +
+
+
+

Posts Shared with you

+ +
+
+
+{% endblock content %} diff --git a/flangr/templates/registration/login.html b/flangr/templates/registration/login.html index 21dad4a..fda684b 100644 --- a/flangr/templates/registration/login.html +++ b/flangr/templates/registration/login.html @@ -1,10 +1,19 @@ {% extends "base.html" %} +{% load django_bootstrap5 %} {% block content %} -

Login

-
- {% csrf_token %} - {{ form }} - -
+
+
+
+

Login

+
+ {% csrf_token %} + {% bootstrap_form form %} + {% bootstrap_button button_type="submit" content="OK" %} +
+
+
+
+ + {% endblock content %} diff --git a/flangr/urls.py b/flangr/urls.py index 19577ed..3485708 100644 --- a/flangr/urls.py +++ b/flangr/urls.py @@ -16,15 +16,20 @@ Including another URLconf from django.conf import settings from django.conf.urls.static import static from django.contrib import admin +from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.urls import include from django.urls import path +from .posts.views import PostListView + urlpatterns = [ path("admin/", admin.site.urls), path("accounts/", include("django.contrib.auth.urls")), path("posts/", include("flangr.posts.urls")), path("circles/", include("flangr.circles.urls")), + path("", PostListView.as_view(), name="home"), ] if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + urlpatterns += staticfiles_urlpatterns() diff --git a/requirements/base.txt b/requirements/base.txt index c49991b..9cf60c8 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,3 +1,4 @@ pillow django coverage +django-bootstrap5 diff --git a/requirements/development.txt b/requirements/development.txt index 3290807..373944e 100644 --- a/requirements/development.txt +++ b/requirements/development.txt @@ -1,2 +1,3 @@ +-r base.txt pre-commit flake8