A big ass commit. This commit converts the existing manual blog domain and theme selection to an automatic process. Closes #8
parent
e3c5646b24
commit
92493cf1a1
|
@ -4,4 +4,4 @@ from accounts.models import UserProfile
|
||||||
class AccountForm(ModelForm):
|
class AccountForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = UserProfile
|
model = UserProfile
|
||||||
fields = ('gittip_username',)
|
exclude = ('user', 'is_pro', 'stripe_id',)
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import datetime
|
||||||
|
from south.db import db
|
||||||
|
from south.v2 import SchemaMigration
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(SchemaMigration):
|
||||||
|
|
||||||
|
def forwards(self, orm):
|
||||||
|
# Adding field 'UserProfile.blog_domain'
|
||||||
|
db.add_column('accounts_userprofile', 'blog_domain',
|
||||||
|
self.gf('django.db.models.fields.CharField')(max_length=250, null=True, blank=True),
|
||||||
|
keep_default=False)
|
||||||
|
|
||||||
|
# Adding field 'UserProfile.blog_title'
|
||||||
|
db.add_column('accounts_userprofile', 'blog_title',
|
||||||
|
self.gf('django.db.models.fields.CharField')(max_length=250, null=True, blank=True),
|
||||||
|
keep_default=False)
|
||||||
|
|
||||||
|
# Adding field 'UserProfile.blog_theme'
|
||||||
|
db.add_column('accounts_userprofile', 'blog_theme',
|
||||||
|
self.gf('django.db.models.fields.CharField')(default='D', max_length=1),
|
||||||
|
keep_default=False)
|
||||||
|
|
||||||
|
|
||||||
|
def backwards(self, orm):
|
||||||
|
# Deleting field 'UserProfile.blog_domain'
|
||||||
|
db.delete_column('accounts_userprofile', 'blog_domain')
|
||||||
|
|
||||||
|
# Deleting field 'UserProfile.blog_title'
|
||||||
|
db.delete_column('accounts_userprofile', 'blog_title')
|
||||||
|
|
||||||
|
# Deleting field 'UserProfile.blog_theme'
|
||||||
|
db.delete_column('accounts_userprofile', 'blog_theme')
|
||||||
|
|
||||||
|
|
||||||
|
models = {
|
||||||
|
'accounts.userprofile': {
|
||||||
|
'Meta': {'object_name': 'UserProfile'},
|
||||||
|
'blog_domain': ('django.db.models.fields.CharField', [], {'max_length': '250', 'null': 'True', 'blank': 'True'}),
|
||||||
|
'blog_theme': ('django.db.models.fields.CharField', [], {'default': "'D'", 'max_length': '1'}),
|
||||||
|
'blog_title': ('django.db.models.fields.CharField', [], {'max_length': '250', 'null': 'True', 'blank': 'True'}),
|
||||||
|
'gittip_username': ('django.db.models.fields.CharField', [], {'max_length': '250', 'null': 'True', 'blank': 'True'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'is_pro': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'stripe_id': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
|
||||||
|
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'unique': 'True'})
|
||||||
|
},
|
||||||
|
'auth.group': {
|
||||||
|
'Meta': {'object_name': 'Group'},
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
|
||||||
|
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
|
||||||
|
},
|
||||||
|
'auth.permission': {
|
||||||
|
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
|
||||||
|
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||||
|
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||||
|
},
|
||||||
|
'auth.user': {
|
||||||
|
'Meta': {'object_name': 'User'},
|
||||||
|
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||||
|
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
|
||||||
|
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||||
|
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||||
|
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||||
|
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||||
|
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||||
|
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||||
|
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
|
||||||
|
},
|
||||||
|
'contenttypes.contenttype': {
|
||||||
|
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
|
||||||
|
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||||
|
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
complete_apps = ['accounts']
|
|
@ -1,12 +1,20 @@
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
class UserProfile(models.Model):
|
class UserProfile(models.Model):
|
||||||
|
|
||||||
|
THEME_CHOICES = (
|
||||||
|
('D', 'Default'),
|
||||||
|
('A', 'Pro Adams'),
|
||||||
|
)
|
||||||
|
|
||||||
user = models.ForeignKey(User, unique=True)
|
user = models.ForeignKey(User, unique=True)
|
||||||
is_pro = models.BooleanField(default=False)
|
is_pro = models.BooleanField(default=False)
|
||||||
stripe_id = models.CharField(max_length=100, null=True, blank=True)
|
stripe_id = models.CharField(max_length=100, null=True, blank=True)
|
||||||
|
|
||||||
gittip_username = models.CharField(max_length=250, null=True, blank=True)
|
gittip_username = models.CharField(max_length=250, null=True, blank=True)
|
||||||
|
blog_title = models.CharField(max_length=250, null=True, blank=True)
|
||||||
|
blog_theme = models.CharField(max_length=1, null=False, blank=False, default='D', choices=THEME_CHOICES)
|
||||||
|
blog_domain = models.CharField(max_length=250, null=True, blank=True)
|
||||||
|
|
||||||
User.profile = property(lambda u: UserProfile.objects.get_or_create(user=u)[0])
|
User.profile = property(lambda u: UserProfile.objects.get_or_create(user=u)[0])
|
||||||
|
|
|
@ -28,10 +28,29 @@
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label" for="id_gittip_username">GitTip username:</label>
|
<label class="control-label" for="id_gittip_username">GitTip username:</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input type="text" id="id_gittip_username" name="gittip_username" value="{% firstof request.user.profile.gittip_username '' %}">
|
{{ form.gittip_username }}
|
||||||
<span class="help-block">Your <a href="https://www.gittip.com/">GitTip</a> username, if you have one.</span>
|
<span class="help-block">Your <a href="https://www.gittip.com/">GitTip</a> username, if you have one.</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="id_blog_title">Blog title:</label>
|
||||||
|
<div class="controls">
|
||||||
|
{{ form.blog_title }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="id_blog_theme">Blog theme:</label>
|
||||||
|
<div class="controls">
|
||||||
|
{{ form.blog_theme }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="id_blog_domain">Blog domain:</label>
|
||||||
|
<div class="controls">
|
||||||
|
{{ form.blog_domain }}
|
||||||
|
<span class="help-block">Like 'snipt.nicksergeant.com' or 'nicksergeant.com' (without quotes). Set your CNAME / A-record to point to 54.243.204.150</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button type="submit" class="btn btn-success">Save</button>
|
<button type="submit" class="btn btn-success">Save</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -18,7 +18,14 @@ def account(request):
|
||||||
return HttpResponseRedirect('/account/')
|
return HttpResponseRedirect('/account/')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
form = AccountForm()
|
profile = request.user.profile
|
||||||
|
|
||||||
|
form = AccountForm(initial={
|
||||||
|
'gittip_username': profile.gittip_username,
|
||||||
|
'blog_title': profile.blog_title,
|
||||||
|
'blog_theme': profile.blog_theme,
|
||||||
|
'blog_domain': profile.blog_domain
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'form': form
|
'form': form
|
||||||
|
|
|
@ -14,7 +14,6 @@ class BlogMiddleware:
|
||||||
if host != 'snipt.net' and host != 'snipt.localhost':
|
if host != 'snipt.net' and host != 'snipt.localhost':
|
||||||
if len(host_s) > 2:
|
if len(host_s) > 2:
|
||||||
if host_s[1] == 'snipt':
|
if host_s[1] == 'snipt':
|
||||||
# nick.snipt.net or nick.snipt.localhost
|
|
||||||
|
|
||||||
blog_user = ''.join(host_s[:-2])
|
blog_user = ''.join(host_s[:-2])
|
||||||
|
|
||||||
|
@ -26,18 +25,9 @@ class BlogMiddleware:
|
||||||
else:
|
else:
|
||||||
request.blog_user = get_object_or_404(User, username__iexact=blog_user)
|
request.blog_user = get_object_or_404(User, username__iexact=blog_user)
|
||||||
|
|
||||||
# TODO: build this into account settings.
|
if request.blog_user is None:
|
||||||
if host == 'rochacbruno.com.br':
|
pro_users = User.objects.filter(userprofile__is_pro=True, username='nick')
|
||||||
request.blog_user = User.objects.get(id=2156)
|
|
||||||
|
|
||||||
if host == 'snips.witsoregon.com':
|
for pro_user in pro_users:
|
||||||
request.blog_user = User.objects.get(id=12291)
|
if host == pro_user.profile.blog_domain:
|
||||||
|
request.blog_user = pro_user
|
||||||
if host == 'snipt.joshhudnall.com':
|
|
||||||
request.blog_user = User.objects.get(id=10325)
|
|
||||||
|
|
||||||
if host == 'nicksergeant.com':
|
|
||||||
request.blog_user = User.objects.get(id=3)
|
|
||||||
|
|
||||||
if host == 'ashleysergeant.com':
|
|
||||||
request.blog_user = User.objects.get(id=18)
|
|
||||||
|
|
|
@ -3,7 +3,14 @@
|
||||||
{% block body-class %}blog-site{% endblock %}
|
{% block body-class %}blog-site{% endblock %}
|
||||||
{% block html-class %}blog-site{% endblock %}
|
{% block html-class %}blog-site{% endblock %}
|
||||||
|
|
||||||
{% block page-title %}{% if blog_user.username == 'nick' %}// Nick Sergeant {% elif blog_user.username == 'blog' %}// Snipt Blog{% else %}// {{ blog_user.username }}{% endif %}{% endblock %}
|
{% block page-title %}
|
||||||
|
//
|
||||||
|
{% if blog_user.profile.blog_title %}
|
||||||
|
{{ blog_user.profile.blog_title }}
|
||||||
|
{% else %}
|
||||||
|
{{ blog_user.username }}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block page-description %}{% endblock %}
|
{% block page-description %}{% endblock %}
|
||||||
{% block rochester-made %}{% endblock %}
|
{% block rochester-made %}{% endblock %}
|
||||||
|
@ -19,10 +26,8 @@
|
||||||
<div class="inner group">
|
<div class="inner group">
|
||||||
<h1>
|
<h1>
|
||||||
<a href="/">
|
<a href="/">
|
||||||
{% if blog_user.username == 'nick' %}
|
{% if blog_user.profile.blog_title %}
|
||||||
Nick Sergeant
|
{{ blog_user.profile.blog_title }}
|
||||||
{% elif blog_user.username == 'blog' %}
|
|
||||||
Snipt Blog
|
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ blog_user.username }}
|
{{ blog_user.username }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -1,39 +1,14 @@
|
||||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||||
<channel>
|
<channel>
|
||||||
{% if request.blog_user.username == 'nick' %}
|
{% if request.blog_user.profile.is_pro %}
|
||||||
<atom:link href="http://nicksergeant.com/?rss" rel="self" type="application/rss+xml" />
|
<atom:link href="{% if request.blog_user.profile.blog_domain %}http://{{ request.blog_user.profile.blog_domain }}/?rss{% else %}https://{{ request.blog_user.username }}.snipt.net/?rss{% endif %}" rel="self" type="application/rss+xml" />
|
||||||
<description>Nick Sergeant</description>
|
<description>{% firstof request.blog_user.profile.blog_title request.blog_user.username %}</description>
|
||||||
<title>Nick Sergeant</title>
|
<title>{% firstof request.blog_user.profile.blog_title request.blog_user.username %}</title>
|
||||||
<link>http://nicksergeant.com/?rss</link>
|
<link>{% if request.blog_user.profile.blog_domain %}http://{{ request.blog_user.profile.blog_domain }}/?rss{% else %}https://{{ request.blog_user.username }}.snipt.net/?rss{% endif %}</link>
|
||||||
{% elif request.blog_user.username == 'ashley' %}
|
|
||||||
<atom:link href="http://ashleysergeant.com/?rss" rel="self" type="application/rss+xml" />
|
|
||||||
<description>Ashley Sergeant</description>
|
|
||||||
<title>Ashley Sergeant</title>
|
|
||||||
<link>http://ashleysergeant.com/?rss</link>
|
|
||||||
{% elif request.blog_user.username == 'gdemaderios' %}
|
|
||||||
<atom:link href="http://snips.witsoregon.com/?rss" rel="self" type="application/rss+xml" />
|
|
||||||
<description>gdemaderios</description>
|
|
||||||
<title>gdemaderios</title>
|
|
||||||
<link>http://snips.witsoregon.com/?rss</link>
|
|
||||||
{% elif request.blog_user.username == 'rochacbruno' %}
|
|
||||||
<atom:link href="http://rochacbruno.com.br/?rss" rel="self" type="application/rss+xml" />
|
|
||||||
<description>Bruno Cezar Rocha</description>
|
|
||||||
<title>Bruno Cezar Rocha</title>
|
|
||||||
<link>http://rochacbruno.com.br/?rss</link>
|
|
||||||
{% elif request.blog_user.username == 'joshhudnall' %}
|
|
||||||
<atom:link href="http://snipt.joshhudnall.com/?rss" rel="self" type="application/rss+xml" />
|
|
||||||
<description>Josh Hudnall</description>
|
|
||||||
<title>Josh Hudnall</title>
|
|
||||||
<link>http://snipt.joshhudnall.com/?rss</link>
|
|
||||||
{% elif request.blog_user.username == 'blog' %}
|
|
||||||
<atom:link href="https://blog.snipt.net/?rss" rel="self" type="application/rss+xml" />
|
|
||||||
<description>Snipt Blog</description>
|
|
||||||
<title>Snipt Blog</title>
|
|
||||||
<link>https://blog.snipt.net/?rss</link>
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<atom:link href="https://{{ request.blog_user.username }}.snipt.net/?rss" rel="self" type="application/rss+xml" />
|
<atom:link href="https://{{ request.blog_user.username }}.snipt.net/?rss" rel="self" type="application/rss+xml" />
|
||||||
<description>{% if request.blog_user.username == 'nick' %}Nick Sergeant{% else %}{{ request.blog_user.username }}{% endif %}</description>
|
<description>{{ request.blog_user.username }}</description>
|
||||||
<title>{% if request.blog_user.username == 'nick' %}Nick Sergeant{% else %}{{ request.blog_user.username }}{% endif %}</title>
|
<title>{{ request.blog_user.username }}</title>
|
||||||
<link>https://{{ request.blog_user.username }}.snipt.net/?rss</link>
|
<link>https://{{ request.blog_user.username }}.snipt.net/?rss</link>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for snipt in snipts %}
|
{% for snipt in snipts %}
|
||||||
|
|
|
@ -6,8 +6,17 @@
|
||||||
|
|
||||||
<title>
|
<title>
|
||||||
{% block page-title %}
|
{% block page-title %}
|
||||||
{% if blog_user.username == 'nick' %}// Nick Sergeant{% elif blog_user.username == 'ashley' %}// Ashley Sergeant{% elif blog_user.username == 'blog' %}// Snipt Blog{% else %}// {{ blog_user.username }}{% endif %}{% endblock %}</title>
|
//
|
||||||
|
{% if blog_user.profile.blog_title %}
|
||||||
|
{{ blog_user.profile.blog_title }}
|
||||||
|
{% else %}
|
||||||
|
{{ blog_user.username }}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
</title>
|
||||||
|
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
|
|
||||||
{% if 'page' in request.GET %}
|
{% if 'page' in request.GET %}
|
||||||
<meta name="robots" content="noindex, follow" />
|
<meta name="robots" content="noindex, follow" />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -52,12 +61,8 @@
|
||||||
</a>
|
</a>
|
||||||
<div class="bio">
|
<div class="bio">
|
||||||
<a class="name" href="/">
|
<a class="name" href="/">
|
||||||
{% if blog_user.username == 'nick' %}
|
{% if blog_user.profile.blog_title %}
|
||||||
Nick Sergeant
|
{{ blog_user.profile.blog_title }}
|
||||||
{% elif blog_user.username == 'blog' %}
|
|
||||||
Snipt Blog
|
|
||||||
{% elif blog_user.username == 'ashley' %}
|
|
||||||
Ashley Sergeant
|
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ blog_user.username }}
|
{{ blog_user.username }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -66,8 +71,7 @@
|
||||||
<p>
|
<p>
|
||||||
I'm a front-end web developer in Rochester, NY working on the <a href="http://amara.org/">Amara</a> project for <a href="http://pculture.org/">PCF</a>. I also created <a href="https://snipt.net/">Snipt</a>.
|
I'm a front-end web developer in Rochester, NY working on the <a href="http://amara.org/">Amara</a> project for <a href="http://pculture.org/">PCF</a>. I also created <a href="https://snipt.net/">Snipt</a>.
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% elif blog_user.username == 'ashley' %}
|
||||||
{% if blog_user.username == 'ashley' %}
|
|
||||||
<p>Life is like photography, we use<br />the negatives to develop.</p>
|
<p>Life is like photography, we use<br />the negatives to develop.</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -86,9 +90,7 @@
|
||||||
projects. View my <a href="/work/">work</a>, then<br />
|
projects. View my <a href="/work/">work</a>, then<br />
|
||||||
<a href="mailto:nick@nicksergeant.com">email me</a>.
|
<a href="mailto:nick@nicksergeant.com">email me</a>.
|
||||||
</p>
|
</p>
|
||||||
<iframe style="border: 0; margin: 0; padding: 0;"
|
<iframe style="border: 0; margin: 0; padding: 0;" src="https://www.gittip.com/nicksergeant/widget.html" width="48pt" height="22pt"></iframe>
|
||||||
src="https://www.gittip.com/nicksergeant/widget.html"
|
|
||||||
width="48pt" height="22pt"></iframe>
|
|
||||||
</section>
|
</section>
|
||||||
<section class="module projects">
|
<section class="module projects">
|
||||||
<h1>Notable projects</h1>
|
<h1>Notable projects</h1>
|
||||||
|
@ -121,8 +123,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
{% endif %}
|
{% elif blog_user.username == 'ashley' %}
|
||||||
{% if blog_user.username == 'ashley' %}
|
|
||||||
<section class="module places">
|
<section class="module places">
|
||||||
<h1>Elsewhere</h1>
|
<h1>Elsewhere</h1>
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -130,6 +131,12 @@
|
||||||
<li><a href="https://twitter.com/ashleysergeant">Twitter</a></li>
|
<li><a href="https://twitter.com/ashleysergeant">Twitter</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
|
{% else %}
|
||||||
|
{% if sidebar %}
|
||||||
|
<section class="module places">
|
||||||
|
{{ sidebar.stylized|safe }}
|
||||||
|
</section>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</aside>
|
</aside>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
from django.shortcuts import get_object_or_404, render_to_response
|
from django.shortcuts import get_object_or_404, render_to_response
|
||||||
from annoying.functions import get_object_or_None
|
from annoying.functions import get_object_or_None
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
from snipts.models import Snipt
|
from snipts.models import Snipt
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
THEME_CHOICES = {
|
||||||
|
'D': 'blogs/themes/default/',
|
||||||
|
'A': 'blogs/themes/pro-adams/',
|
||||||
|
}
|
||||||
|
|
||||||
def blog_list(request, username_or_custom_slug=None):
|
def blog_list(request, username_or_custom_slug=None):
|
||||||
|
|
||||||
|
@ -41,10 +44,12 @@ def blog_list(request, username_or_custom_slug=None):
|
||||||
context['snipts'] = context['snipts'][:20]
|
context['snipts'] = context['snipts'][:20]
|
||||||
return rss(request, context)
|
return rss(request, context)
|
||||||
|
|
||||||
if request.blog_user.profile.is_pro and request.blog_user.username in ['nick', 'ashley']:
|
if request.blog_user.profile.is_pro:
|
||||||
template = 'blogs/themes/pro-adams/list.html'
|
template = THEME_CHOICES[request.blog_user.profile.blog_theme]
|
||||||
else:
|
else:
|
||||||
template = 'blogs/themes/default/list.html'
|
template = THEME_CHOICES['D']
|
||||||
|
|
||||||
|
template = '{}/list.html'.format(template)
|
||||||
|
|
||||||
return render_to_response(
|
return render_to_response(
|
||||||
template,
|
template,
|
||||||
|
@ -84,10 +89,12 @@ def blog_post(request, username_or_custom_slug):
|
||||||
'snipt': snipt,
|
'snipt': snipt,
|
||||||
}
|
}
|
||||||
|
|
||||||
if request.blog_user.profile.is_pro and request.blog_user.username in ['nick', 'ashley']:
|
if request.blog_user.profile.is_pro:
|
||||||
template = 'blogs/themes/pro-adams/post.html'
|
template = THEME_CHOICES[request.blog_user.profile.blog_theme]
|
||||||
else:
|
else:
|
||||||
template = 'blogs/themes/default/post.html'
|
template = THEME_CHOICES['D']
|
||||||
|
|
||||||
|
template = '{}/post.html'.format(template)
|
||||||
|
|
||||||
return render_to_response(
|
return render_to_response(
|
||||||
template,
|
template,
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1420,6 +1420,11 @@ body.account {
|
||||||
div.control-group:first-of-type {
|
div.control-group:first-of-type {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
|
span.help-block {
|
||||||
|
color: #999;
|
||||||
|
font-size: 12px;
|
||||||
|
max-width: 370px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,19 +126,8 @@ class Snipt(models.Model):
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
|
|
||||||
if self.blog_post:
|
if self.blog_post:
|
||||||
if self.user.id == 3:
|
if self.user.profile.is_pro and self.user.profile.blog_domain is not None:
|
||||||
if settings.DEBUG:
|
return 'http://{}/{}/'.format(self.user.profile.blog_domain, self.slug)
|
||||||
return 'http://nick.snipt.localhost/{}/'.format(self.slug)
|
|
||||||
else:
|
|
||||||
return 'http://nicksergeant.com/{}/'.format(self.slug)
|
|
||||||
elif self.user.id == 18:
|
|
||||||
return 'http://ashleysergeant.com/{}/'.format(self.slug)
|
|
||||||
elif self.user.id == 12291:
|
|
||||||
return 'http://snips.witsoregon.com/{}/'.format(self.slug)
|
|
||||||
elif self.user.id == 2156:
|
|
||||||
return 'http://rochacbruno.com.br/{}/'.format(self.slug)
|
|
||||||
elif self.user.id == 10325:
|
|
||||||
return 'http://snipt.joshhudnall.com/{}/'.format(self.slug)
|
|
||||||
else:
|
else:
|
||||||
return 'https://{}.snipt.net/{}/'.format(self.user.username.replace('_', '-'), self.slug)
|
return 'https://{}.snipt.net/{}/'.format(self.user.username.replace('_', '-'), self.slug)
|
||||||
|
|
||||||
|
@ -153,19 +142,8 @@ class Snipt(models.Model):
|
||||||
def get_full_absolute_url(self):
|
def get_full_absolute_url(self):
|
||||||
|
|
||||||
if self.blog_post:
|
if self.blog_post:
|
||||||
if self.user.id == 3:
|
if self.user.profile.is_pro and self.user.profile.blog_domain is not None:
|
||||||
if settings.DEBUG:
|
return 'http://{}/{}/'.format(self.user.profile.blog_domain, self.slug)
|
||||||
return 'http://nick.snipt.localhost/{}/'.format(self.slug)
|
|
||||||
else:
|
|
||||||
return 'http://nicksergeant.com/{}/'.format(self.slug)
|
|
||||||
elif self.user.id == 18:
|
|
||||||
return 'http://ashleysergeant.com/{}/'.format(self.slug)
|
|
||||||
elif self.user.id == 12291:
|
|
||||||
return 'http://snips.witsoregon.com/{}/'.format(self.slug)
|
|
||||||
elif self.user.id == 2156:
|
|
||||||
return 'http://rochacbruno.com.br/{}/'.format(self.slug)
|
|
||||||
elif self.user.id == 10325:
|
|
||||||
return 'http://snipt.joshhudnall.com/{}/'.format(self.slug)
|
|
||||||
else:
|
else:
|
||||||
return 'https://{}.snipt.net/{}/'.format(self.user.username, self.slug)
|
return 'https://{}.snipt.net/{}/'.format(self.user.username, self.slug)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue