Some user profile stuff.
parent
8e0cfc07e2
commit
55a973f971
|
@ -69,5 +69,21 @@ class UserProfile(models.Model):
|
|||
else:
|
||||
return self.blog_domain.split(' ')[0]
|
||||
|
||||
def get_user_profile_url(self):
|
||||
|
||||
# If the user has a blog domain, use that.
|
||||
if self.blog_domain:
|
||||
url = 'http://{}'.format(self.get_primary_blog_domain())
|
||||
|
||||
# Otherwise, if they have blog posts, use their Snipt blog URL.
|
||||
elif self.get_blog_posts():
|
||||
url = 'https://{}.snipt.net/'.format(self.user.username)
|
||||
|
||||
# Otherwise, use their regular Snipt profile page.
|
||||
else:
|
||||
url = 'https://snipt.net/{}/'.format(self.user.username)
|
||||
|
||||
return url
|
||||
|
||||
|
||||
User.profile = property(lambda u: UserProfile.objects.get_or_create(user=u)[0])
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -575,17 +575,16 @@ section.main {
|
|||
border-bottom: 1px solid #5AB6F4;
|
||||
}
|
||||
}
|
||||
div.alt-links {
|
||||
margin: 0 0 30px 22px;
|
||||
}
|
||||
a.alt-link {
|
||||
display: inline-block;
|
||||
font-weight: bold;
|
||||
margin: 0 0 10px 22px;
|
||||
|
||||
&.active {
|
||||
color: #2B6E9B;
|
||||
}
|
||||
&.favorites {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
nav.footer {
|
||||
|
@ -1460,6 +1459,18 @@ div.profile {
|
|||
text-transform: uppercase;
|
||||
}
|
||||
}
|
||||
div.urls {
|
||||
border-top: 1px solid #D8D8D8;
|
||||
color: #909090;
|
||||
line-height: 15px;
|
||||
font-size: 11px;
|
||||
margin-top: 10px;
|
||||
padding: 9px 0 5px 0;
|
||||
|
||||
a {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
a.pro {
|
||||
background: #DFDFDF;
|
||||
color: #3299B7;
|
||||
|
|
|
@ -82,19 +82,7 @@ class Snipt(models.Model):
|
|||
user = get_object_or_None(User, username=match)
|
||||
|
||||
if user:
|
||||
|
||||
# If the user has a blog domain, use that.
|
||||
if user.profile.get_primary_blog_domain():
|
||||
url = 'http://{}'.format(user.profile.get_primary_blog_domain())
|
||||
|
||||
# Otherwise, if they have blog posts, use their Snipt blog URL.
|
||||
elif user.profile.get_blog_posts():
|
||||
url = 'https://{}.snipt.net/'.format(user.username)
|
||||
|
||||
# Otherwise, use their regular Snipt profile page.
|
||||
else:
|
||||
url = 'https://snipt.net/{}/'.format(match)
|
||||
|
||||
url = user.profile.get_user_profile_url()
|
||||
self.stylized = self.stylized.replace('@{}'.format(str(match)), '<a href="{}">@{}</a>'.format(url, match))
|
||||
|
||||
else:
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
<section class="tags">
|
||||
{% if request.user == user %}
|
||||
<a href="/{{ user }}/favorites/" class="alt-link favorites {% if 'favorites' in request.path %}active{% endif %}"><span>View favorited snipts »</span></a>
|
||||
{% endif %}
|
||||
<a href="/{{ user }}/blog-posts/" class="alt-link {% if 'blog-posts' in request.path %}active{% endif %}"><span>View blog posts »</span></a>
|
||||
<div class="alt-links">
|
||||
{% if request.user == user %}
|
||||
<a href="/{{ user }}/favorites/" class="alt-link favorites {% if 'favorites' in request.path %}active{% endif %}"><span>View favorited snipts »</span></a>
|
||||
{% endif %}
|
||||
{% if request.user.profile.get_blog_posts %}
|
||||
<a href="/{{ user }}/blog-posts/" class="alt-link {% if 'blog-posts' in request.path %}active{% endif %}"><span>View blog posts »</span></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if tags %}
|
||||
<h1>{{ user.username }}'s tags</h1>
|
||||
<ul>
|
||||
|
|
|
@ -1,23 +1,27 @@
|
|||
{% load snipt_tags %}
|
||||
|
||||
<div class="profile group">
|
||||
<img src="https://secure.gravatar.com/avatar/{{ user.email|md5 }}?s=175" alt="{{ user.username }}" title={{ user.username }}" />
|
||||
<a href="/{{ user.username }}/">
|
||||
<img src="https://secure.gravatar.com/avatar/{{ user.email|md5 }}?s=175" alt="{{ user.username }}" title="{{ user.username }}" />
|
||||
</a>
|
||||
<div class="meta">
|
||||
<div class="username" title="{{ user.username }}">
|
||||
{% if user.username == 'blog' %}
|
||||
Blog
|
||||
{% else %}
|
||||
<a href="">
|
||||
{{ user.username }}
|
||||
{% endif %}
|
||||
</a>
|
||||
</div>
|
||||
{% if user.username == 'nick' %}
|
||||
<div class="member-since">Snipt Founder in {{ user.date_joined|date:"Y" }}</div>
|
||||
{% else %}
|
||||
{% if user.username == 'blog' %}
|
||||
<div class="member-since">Official Snipt blog</div>
|
||||
{% else %}
|
||||
<div class="member-since">Member since {{ user.date_joined|date:"Y" }}</div>
|
||||
{% endif %}
|
||||
<div class="member-since">Member since {{ user.date_joined|date:"Y" }}</div>
|
||||
{% endif %}
|
||||
{% if user.profile.is_pro and user.profile.get_blog_posts %}
|
||||
<div class="urls">
|
||||
Snipt Blog:
|
||||
<a href="{{ user.profile.get_user_profile_url }}">
|
||||
{{ user.profile.get_user_profile_url }}
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if user.profile.is_pro %}
|
||||
|
|
Loading…
Reference in New Issue