Skip to content

Commit ea81bab

Browse files
authored
Merge branch 'develop' into reload
2 parents f20a8e5 + 05137fa commit ea81bab

File tree

22 files changed

+435
-135
lines changed

22 files changed

+435
-135
lines changed

.all-contributorsrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,15 @@
10051005
"contributions": [
10061006
"code"
10071007
]
1008+
},
1009+
{
1010+
"login": "Nehemiah60",
1011+
"name": "Nehemiah60",
1012+
"avatar_url": "https://avatars.githubusercontent.com/u/87471613?v=4",
1013+
"profile": "https://twitter.com/nehemiah_bosire",
1014+
"contributions": [
1015+
"code"
1016+
]
10081017
}
10091018
],
10101019
"contributorsPerLine": 7,

README.md

Lines changed: 11 additions & 8 deletions
Large diffs are not rendered by default.

poetry.lock

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

project/accounts/factory.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import factory
2+
import factory.fuzzy
3+
from django.contrib.auth.models import User
4+
5+
from .modes import Profile
6+
7+
8+
class UserFactory(factory.django.DjangoModelFactory):
9+
class Meta:
10+
model = User
11+
12+
username = factory.Faker("sentence", nb_words=20)
13+
14+
15+
class ProfileFactory(factory.django.DjangoModelFactory):
16+
class Meta:
17+
model = Profile
18+
19+
user = factory.SubFactory("app.factories.UserFactory")
20+
first_name = factory.Faker("lorem")
21+
last_name = factory.Faker("lorem")
22+
about_me = factory.Faker("lorem")
23+
is_verified = factory.fuzzy.FuzzyChoice(choices=[True, False])
24+
profile_image = factory.Faker("image_url")
25+
profile_image_thumb = factory.Faker("image_url")
26+
27+
@factory.post_generation
28+
def categories(self, create, extracted, **kwargs):
29+
if not create:
30+
return
31+
if extracted:
32+
for category in extracted:
33+
self.categories.add(category)
34+
35+
@factory.post_generation
36+
def tags(self, create, extracted, **kwargs):
37+
if not create:
38+
return
39+
if extracted:
40+
for tag in extracted:
41+
self.tags.add(tag)
42+
43+
@factory.post_generation
44+
def following(self, create, extracted, **kwargs):
45+
if not create:
46+
return
47+
if extracted:
48+
for follower in extracted:
49+
self.following.add(follower)

project/accounts/templates/accounts/account.html

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,48 @@
33
{% load i18n %}
44

55
{% block extra_css %}
6-
<link type="text/css" rel="stylesheet/less" href="{% static 'less/base.less' %}"/>
7-
<link type="text/css" rel="stylesheet/less" href="{% static 'less/utils.less' %}"/>
8-
<link type="text/css" rel="stylesheet/less" href="{% static 'less/account.less' %}"/>
6+
<link type="text/css" rel="stylesheet/less" href="{% static 'less/base.less' %}" />
7+
<link type="text/css" rel="stylesheet/less" href="{% static 'less/utils.less' %}" />
8+
<link type="text/css" rel="stylesheet/less" href="{% static 'less/account.less' %}" />
99
{% endblock extra_css %}
1010

1111
{% block content %}
1212
<div id="account">
1313
<div id="sidebar-template">
1414
<div class="profile-image">
1515
<div class="big-image-cropper z-depth-1">
16-
<img
17-
class="responsive-img"
18-
src={{ profile.profile_image_url }}
19-
/>
16+
<img class="responsive-img" src={{ profile.profile_image_url }} />
2017
</div>
2118
</div>
22-
2319
<!-- Prevent users from following themselves. -->
2420
{% if not profile == request.user.profile %}
25-
{% if profile not in request.user.profile.following.all %}
26-
<a href="{% url 'profile-follow' profile.user.username %}" class="waves-effect waves-light btn follow-btn" id="sidebar-follow-btn">
27-
follow
28-
</a>
29-
{% else %}
30-
<a href="{% url 'profile-unfollow' profile.user.username %}" class="waves-effect waves-light btn follow-btn" id="sidebar-follow-btn">
31-
unfollow
32-
</a>
33-
{% endif %}
21+
{% if profile not in request.user.profile.following.all %}
22+
<a href="{% url 'profile-follow' profile.user.username %}" class="waves-effect waves-light btn follow-btn"
23+
id="sidebar-follow-btn">
24+
follow
25+
</a>
26+
{% else %}
27+
<a href="{% url 'profile-unfollow' profile.user.username %}" class="waves-effect waves-light btn follow-btn"
28+
id="sidebar-follow-btn">
29+
unfollow
30+
</a>
31+
{% endif %}
3432
{% endif %}
35-
3633
<div class="user-info section">
3734
<div class="full-name">
3835
{{ profile.first_name }} {{ profile.last_name }}
3936
</div>
4037
<div class="username">@{{ username }}</div>
4138
</div>
39+
<div class="categories">
40+
<ul>
41+
{%for category in profile.categories.all%}
42+
<li>
43+
{{category}}
44+
</li>
45+
{%endfor%}
46+
</ul>
47+
</div>
4248
<div class="transparent">
4349
<div class="card-content">
4450
<div class="section">

project/accounts/templates/accounts/user_civis.html

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,39 @@
22
{% load i18n %}
33

44
{% block content %}
5-
{% for civi in civis %}
6-
<div class="civi-card white" data-id="">
7-
<div class="civi-header-account white">
8-
<div class="civi-title-outer">
9-
<div class="civi-type gray-text">{{ civi.c_type }}</div>
10-
<div class="civi-title">{{ civi.title }}</div>
11-
</div>
12-
</div>
13-
<div class="civi-body">
14-
<div class="civi-body-inner">{{ civi.body }}</div>
15-
</div>
5+
{% for civi in civis %}
6+
<div class="civi-card white" data-id="">
7+
<div class="civi-header-account white">
8+
<div class="civi-title-outer">
9+
<div class="civi-type gray-text">{{ civi.c_type }}</div>
10+
<div class="civi-title">{{ civi.title }}</div>
1611
</div>
17-
{% empty %}
18-
<div class="section no-state">
19-
<div class="container">
20-
<div class="section">
21-
<div class="center title-lato text">No activity</div>
22-
</div>
23-
</div>
12+
</div>
13+
<div class="civi-body">
14+
<div class="civi-body-inner">{{ civi.body }}</div>
15+
</div>
16+
</div>
17+
{% empty %}
18+
<div class="section no-state">
19+
<div class="container">
20+
<div class="section">
21+
<div class="center title-lato text">No activity</div>
2422
</div>
25-
{% endfor %}
23+
</div>
24+
</div>
25+
{% endfor %}
2626

27+
{% for follower in followers%}
28+
<div class="col s12 m6">
29+
<div class="user-chip chip white">
30+
<div class="user-chip-contents">
31+
<a href="/profile/{{ follower.user.username }}/">
32+
<img src="{{ follower.profile_image_url }}" alt="{{ followers.user.username }}">
33+
@{{ follower.user.username }}
34+
</a>
35+
</div>
36+
</div>
37+
</div>
38+
{%endfor%}
2739

2840
{% endblock content %}

project/accounts/urls.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
PasswordResetView,
66
ProfileActivationView,
77
ProfileFollow,
8+
ProfileFollowing,
89
ProfileUnfollow,
910
RegisterView,
1011
SettingsView,
12+
UserCivis,
1113
UserFollowers,
12-
ProfileFollowing,
14+
UserIssues,
1315
UserProfileView,
14-
UserCivis,
1516
expunge_user,
1617
)
1718
from django.contrib.auth import views as auth_views
@@ -55,6 +56,11 @@
5556
UserCivis.as_view(),
5657
name="user-civis",
5758
),
59+
path(
60+
"profile/<str:username>/issues/",
61+
UserIssues.as_view(),
62+
name="user-issues",
63+
),
5864
path(
5965
"accounts/password_reset/",
6066
PasswordResetView.as_view(),

project/accounts/views.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ class UserProfileView(LoginRequiredMixin, View):
178178

179179
def get(self, request, username=None):
180180
profile = get_object_or_404(Profile, user__username=username)
181-
182181
return TemplateResponse(
183182
request,
184183
"account.html",
@@ -188,13 +187,11 @@ def get(self, request, username=None):
188187
)
189188

190189

191-
192190
class UserFollowers(LoginRequiredMixin, View):
193191
"""A view that shows the followers for authorized users"""
194-
192+
195193
def get(self, request, username=None):
196194
profile = get_object_or_404(Profile, user__username=username)
197-
198195
return TemplateResponse(
199196
request,
200197
"user_followers.html",
@@ -215,16 +212,13 @@ def get(self, request, username=None):
215212

216213
return TemplateResponse(
217214
request,
218-
219215
"profile_following.html",
220-
221216
{
222217
"profile": profile,
223218
},
224219
)
225220

226221

227-
228222
class UserCivis(LoginRequiredMixin, View):
229223
"""
230224
A view that shows list of civis
@@ -243,7 +237,6 @@ def get(self, request, username=None):
243237
)
244238

245239

246-
247240
@login_required
248241
def expunge_user(request):
249242
"""
@@ -276,3 +269,17 @@ def expunge_user(request):
276269
profile.save()
277270

278271
return redirect("/")
272+
273+
274+
class UserIssues(LoginRequiredMixin, View):
275+
def get(self, request, username=None):
276+
profile = get_object_or_404(Profile, user__username=username)
277+
user = profile.user
278+
civis = user.civis.all()
279+
followers = profile.followers.all()
280+
281+
return TemplateResponse(
282+
request,
283+
"user_civis.html",
284+
{"profile": profile, "followers": followers, "civis": civis},
285+
)

project/categories/factory.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import factory
2+
3+
from .models import Category
4+
5+
6+
class CategoryFactory(factory.django.DjangoModelFactory):
7+
class Meta:
8+
model = Category
9+
10+
name = factory.Faker("lorem")

0 commit comments

Comments
 (0)