mirror of
https://github.com/kristoferssolo/FOSSDB.git
synced 2025-10-21 17:50:35 +00:00
Fix user profile
This commit is contained in:
parent
065bb127ba
commit
76bc5fad60
@ -4,15 +4,24 @@
|
||||
{% block meta %}{% endblock %}
|
||||
{% block content %}
|
||||
<div class="py-8 px-32">
|
||||
<div class="flex justify-end gap-4">
|
||||
<a href="{% url "logout" %}">
|
||||
<i class="fa-solid fa-right-from-bracket fa-2xl"></i>
|
||||
</a>
|
||||
<a href="{% url "settings" %}">
|
||||
<i class="fa-solid fa-gear fa-2xl"></i>
|
||||
</a>
|
||||
</div>
|
||||
<h1 class="font-abel text-4xl mb-8">My Projects</h1>
|
||||
{% if user.is_authenticated and user == page_owner %}
|
||||
<div class="flex justify-end gap-4">
|
||||
<a href="{% url "logout" %}">
|
||||
<i class="fa-solid fa-right-from-bracket fa-2xl"></i>
|
||||
</a>
|
||||
<a href="{% url "settings" %}">
|
||||
<i class="fa-solid fa-gear fa-2xl"></i>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<h1 class="font-abel text-4xl mb-8">
|
||||
{% if user.is_authenticated and user == page_owner %}
|
||||
My
|
||||
{% else %}
|
||||
{{ page_owner }}
|
||||
{% endif %}
|
||||
Projects
|
||||
</h1>
|
||||
<div class="grid grid-cols-1 gap-4">
|
||||
{% for project in projects %}
|
||||
<div class="border border-steelblue-100 p-8 flex flex-row gap-4 justify-between">
|
||||
|
||||
@ -4,9 +4,7 @@ from django.contrib.auth.forms import PasswordChangeForm
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.shortcuts import redirect, render
|
||||
from django.urls import reverse_lazy
|
||||
from django.views.generic import ListView, TemplateView, View
|
||||
|
||||
from fossdb.models import Project
|
||||
from django.views.generic import TemplateView, View
|
||||
|
||||
from .forms import LoginForm, SignUpForm, UserChangeForm
|
||||
|
||||
@ -64,22 +62,6 @@ class PasswordChangeView(LoginRequiredMixin, TemplateView):
|
||||
return self.render_to_response(context)
|
||||
|
||||
|
||||
class ProfileProjectListView(LoginRequiredMixin, ListView):
|
||||
model = Project
|
||||
template_name = "profile.html"
|
||||
context_object_name = "projects"
|
||||
login_url = reverse_lazy("login")
|
||||
redirect_field_name = "redirect_to"
|
||||
|
||||
def get_queryset(self):
|
||||
return Project.objects.filter(owner=self.request.user)
|
||||
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
data = super().get_context_data(**kwargs)
|
||||
data["title"] = self.request.user.username + ("" if not self.request.user.full_name else f" ({self.request.user.full_name})")
|
||||
return data
|
||||
|
||||
|
||||
def signup_view(request):
|
||||
form = SignUpForm(request.POST or None)
|
||||
if request.method == "POST":
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
|
||||
from django.db.models import Q
|
||||
from django.shortcuts import redirect
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.urls import reverse_lazy
|
||||
|
||||
from django.views.generic import CreateView, DeleteView, DetailView, ListView, UpdateView
|
||||
@ -34,6 +35,24 @@ class SearchResultsListView(ListView):
|
||||
return data
|
||||
|
||||
|
||||
class ProfileProjectListView(ListView):
|
||||
model = Project
|
||||
template_name = "profile.html"
|
||||
context_object_name = "projects"
|
||||
slug_field = "username"
|
||||
|
||||
def get_queryset(self):
|
||||
username = self.kwargs.get("username")
|
||||
self.user = get_object_or_404(get_user_model(), username=username)
|
||||
return Project.objects.filter(owner__username=username)
|
||||
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
data = super().get_context_data(**kwargs)
|
||||
data["title"] = self.user.username + ("" if not self.user.full_name else f" ({self.user.full_name})")
|
||||
data["page_owner"] = self.user
|
||||
return data
|
||||
|
||||
|
||||
class ProjectListView(ListView):
|
||||
model = Project
|
||||
template_name = "explore.html"
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
from account.views import ProfileProjectListView
|
||||
from django.urls import path
|
||||
from fossdb.views import ProjectCreateView, ProjectListView, SearchResultsListView
|
||||
from fossdb.views import ProfileProjectListView, ProjectCreateView, ProjectListView, SearchResultsListView
|
||||
|
||||
from . import views
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user