Make it free to post public snipts.

master
Nick Sergeant 2015-08-25 12:01:48 -04:00
parent 5e50c3be21
commit f13dc219c5
9 changed files with 32 additions and 41 deletions

View File

@ -111,12 +111,12 @@
$selectLexer.chosen(); $selectLexer.chosen();
// Blog post // Blog post
$('label.blog-post input', window.site.$main_edit).on('change', function() { $('label.blog-post input', window.site.$main_edit).change(function() {
var $checkbox = $(this); var $checkbox = $(this);
var $label = $checkbox.parent(); var $label = $checkbox.parent();
var $publish_date = $label.siblings('label.publish-date'); var $publish_date = $label.siblings('label.publish-date');
if ($checkbox.attr('checked')) { if ($checkbox.is(':checked')) {
$label.removeClass('is-not-blog-post').addClass('is-blog-post'); $label.removeClass('is-not-blog-post').addClass('is-blog-post');
$publish_date.show(); $publish_date.show();
} else { } else {
@ -124,20 +124,23 @@
$publish_date.hide(); $publish_date.hide();
} }
return false; return false;
}).trigger('change'); }).change();
// Public / private // Public / private
$('label.public input', window.site.$main_edit).on('change', function() { $('label.public input', window.site.$main_edit).change(function() {
var $checkbox = $(this); var $checkbox = $(this);
var $label = $checkbox.parent(); var $label = $checkbox.parent();
if ($checkbox.attr('checked')) { $('div.alert-not-pro').hide();
if ($checkbox.is(':checked')) {
$label.removeClass('is-private').addClass('is-public'); $label.removeClass('is-private').addClass('is-public');
if (!window.user_is_pro) $('div.alert-not-pro').hide();
} else { } else {
$label.addClass('is-private').removeClass('is-public'); $label.addClass('is-private').removeClass('is-public');
if (!window.user_is_pro) $('div.alert-not-pro').show();
} }
return false; return false;
}).trigger('change'); }).change();
window.site.$main_edit.show(); window.site.$main_edit.show();
@ -488,7 +491,7 @@
window.site.$main_edit).removeAttr('disabled'); window.site.$main_edit).removeAttr('disabled');
}, },
error: function(model, response) { error: function(model, response) {
alert('There was a problem saving your snipt. We\'ve been notified. Sorry about that!'); alert(JSON.stringify(response.responseJSON.snipt));
} }
}); });
}, },
@ -588,11 +591,7 @@
$('span.cmd-ctrl').text(cmd); $('span.cmd-ctrl').text(cmd);
$('button#add-snipt').click(function() { $('button#add-snipt').click(function() {
if (window.user_account_age > 7 && !window.user_is_pro) { that.addNewSnipt();
window.location = '/pro/?expired=true';
} else {
that.addNewSnipt();
}
}); });
}, },
@ -682,7 +681,7 @@
lexer: 'text', lexer: 'text',
lexer_name: 'Text only', lexer_name: 'Text only',
new_from_js: true, new_from_js: true,
public: false, public: true,
user: { user: {
username: '', username: '',
profile: { profile: {

View File

@ -145,12 +145,14 @@ class SniptValidation(Validation):
def is_valid(self, bundle, request=None): def is_valid(self, bundle, request=None):
errors = {} errors = {}
if 'pk' not in bundle.data and \ print bundle.data['public']
request.user.profile.get_account_age() > 7 and \
if bundle.data['public'] is False and \
request.user.profile.is_pro is False: request.user.profile.is_pro is False:
errors['expired'] = """Your trial has expired. You'll need errors['not-pro'] = ("You'll need to go Pro "
to go Pro (https://snipt.net/pro/) "(https://snipt.net/pro/) "
in order to create new snipts.""" "in order to create private "
"snipts.")
return errors return errors
@ -162,9 +164,9 @@ class UserProfileValidation(Validation):
for field in bundle.data: for field in bundle.data:
if bundle.data[field]: if bundle.data[field]:
if not re.match('^[ A-Za-z0-9\/\@\._-]*$', bundle.data[field]): if not re.match('^[ A-Za-z0-9\/\@\._-]*$', bundle.data[field]):
errors[field] = """Only spaces, letters, numbers, errors[field] = ("Only spaces, letters, numbers, "
underscores, dashes, periods, forward "underscores, dashes, periods, forward "
slashes, and "at sign" are valid.""" "slashes, and \"at sign\" are valid.")
return errors return errors

View File

@ -50,8 +50,6 @@
<section class="snipts" id="snipts"> <section class="snipts" id="snipts">
{% if not request.user.is_authenticated %} {% if not request.user.is_authenticated %}
{% include 'ad-leaderboard-pro.html' %} {% include 'ad-leaderboard-pro.html' %}
{% elif not request.user.profile.teams_beta_seen %}
{% include 'ad-leaderboard-pro.html' %}
{% endif %} {% endif %}
{% with 'true' as detail %} {% with 'true' as detail %}
{% include "snipts/snipt-list.html" %} {% include "snipts/snipt-list.html" %}

View File

@ -18,8 +18,6 @@
{% endif %}> {% endif %}>
{% if not request.user.is_authenticated %} {% if not request.user.is_authenticated %}
{% include 'ad-leaderboard-pro.html' %} {% include 'ad-leaderboard-pro.html' %}
{% elif not request.user.profile.teams_beta_seen %}
{% include 'ad-leaderboard-pro.html' %}
{% endif %} {% endif %}
{% autopaginate snipts 10 %} {% autopaginate snipts 10 %}
{% for snipt in snipts %} {% for snipt in snipts %}

View File

@ -23,6 +23,9 @@
<div class="group"> <div class="group">
<div class="container"> <div class="container">
<header> <header>
<div class="alert alert-error alert-not-pro" style="display: none; margin: 10px 10px -10px 10px;">
You'll need to go Pro (<a href="https://snipt.net/pro/">https://snipt.net/pro/</a>) in order to create private snipts.
</div>
<h2>&nbsp;</h2> <h2>&nbsp;</h2>
<h1> <h1>
<input type="text" id="snipt_title" placeholder="Title" value="<% if (snipt.title != 'Untitled') { %><%= snipt.title %><% } %>" /> <input type="text" id="snipt_title" placeholder="Title" value="<% if (snipt.title != 'Untitled') { %><%= snipt.title %><% } %>" />

View File

@ -1,4 +1,4 @@
<a href="/for-teams/" class="snipt-promo"> <a href="/signup" class="snipt-promo">
<button class="btn btn-success btn-large pull-right">More info &raquo;</button> <button class="btn btn-success btn-large pull-right">Sign up &raquo;</button>
Announcing Snipt for Teams! <br />Starting at just $49/month. Sign up for Snipt!<br /><span style="font-size: 16px;">Post public snipts for free. Private snipts just $5/mo.</span>
</a> </a>

View File

@ -369,7 +369,6 @@
window.user_ip = '{{ request.META.REMOTE_ADDR }}'; window.user_ip = '{{ request.META.REMOTE_ADDR }}';
window.user_profile_id = {% firstof request.user.profile.id 'null' %}; window.user_profile_id = {% firstof request.user.profile.id 'null' %};
window.user_email = '{{ request.user.email }}'; window.user_email = '{{ request.user.email }}';
window.user_account_age = {% firstof request.user.profile.get_account_age 'null' %};
{% if public %} {% if public %}
window.pub = {{ public|lower }}; window.pub = {{ public|lower }};

View File

@ -22,11 +22,6 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
{% if request.GET.expired %}
<div class="alert alert-error" style="margin: 30px; padding-right: 14px;">
<strong>Your trial has expired.</strong> You'll need to go Pro in order to create new snipts.
</div>
{% endif %}
{% if request.GET.declined %} {% if request.GET.declined %}
<div class="alert alert-error" style="margin: 30px;"> <div class="alert alert-error" style="margin: 30px;">
<strong>{{ request.GET.declined }}</strong> You have not been charged. Please try again. <strong>{{ request.GET.declined }}</strong> You have not been charged. Please try again.
@ -37,7 +32,8 @@
<div class="info"> <div class="info">
Go <span class="pro">Pro</span> for just <span>$5/month</span>. Go <span class="pro">Pro</span> for just <span>$5/month</span>.
<p class="sub"> <p class="sub">
As a paid Snipt member, you'll have unrestricted access to the app, <a href="/api/">API</a>, As a paid Snipt member you'll unlock the ability to post private snipts,
have unrestricted access to the app, <a href="/api/">API</a>,
custom-domain <a href="/blogging/">blogging</a>, instant chat support, and more. custom-domain <a href="/blogging/">blogging</a>, instant chat support, and more.
</p> </p>
<p class="sub" style="font-size: .6em; margin-top: 15px;"> <p class="sub" style="font-size: .6em; margin-top: 15px;">

View File

@ -21,12 +21,8 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
<fieldset> <fieldset>
<div class="info"> <div class="info" style="line-height: 35px;">
Free for 7 days, then just <span>$5/month</span>. Free to post public snipts,<br />just <span>$5/month</span> for private snipts.
<p class="sub">
Your free trial comes with unrestricted access to the app,<br />
<a href="/api/">API</a>, instant chat support, and more.
</p>
</div> </div>
<div class="control-group {% if form.errors.username %}error{% endif %}"> <div class="control-group {% if form.errors.username %}error{% endif %}">
<label class="control-label" for="id_username">Username</label> <label class="control-label" for="id_username">Username</label>