Skip to content
Permalink
Browse files

Remove user e-mails from site

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Mar 23, 2017
1 parent f33056e commit 3aeb661b9d237514ea0aa867ec98aec616859719
@@ -7,7 +7,7 @@ class LanguageAdmin(admin.ModelAdmin):
list_display = ('name', 'code', 'language_code', 'country_code', 'display_country')

class SiteAdmin(admin.ModelAdmin):
list_display = ('title', 'clickable_url', 'author_link_always', 'visible', 'featured')
list_display = ('title', 'clickable_url', 'author', 'visible', 'featured')

def make_visible(modeladmin, request, queryset):
queryset.update(visible=True)
@@ -4,16 +4,15 @@
def make_choices():
return [(l.code, l.name) for l in Language.objects.all().order_by('name')]


class AddForm(forms.Form):
title = forms.CharField(label="Title", max_length=100)
url = forms.URLField(label="URL", max_length=512)
author = forms.CharField(label="Author", max_length=100)
email = forms.EmailField(label="E-mail address", max_length=100)
description = forms.CharField(label="Description", max_length=250)
sourcelink = forms.URLField(label="Site source", max_length=512, required=False)
languages = forms.MultipleChoiceField(label="Languages", required=False, choices=make_choices)
tos = forms.BooleanField(label="Accept TOS")
publish_email = forms.BooleanField(label="Publish e-mail", required=False)


class CheckForm(forms.Form):
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2017-03-23 20:09
from __future__ import unicode_literals

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('sites', '0001_initial'),
]

operations = [
migrations.RemoveField(
model_name='site',
name='email',
),
migrations.RemoveField(
model_name='site',
name='publish_email',
),
]
@@ -32,13 +32,11 @@ class Site(models.Model):
title = models.CharField(max_length=100)
url = models.URLField("Site URL", max_length=512, unique=True)
author = models.CharField(max_length=100)
email = models.EmailField(max_length=100)
description = models.TextField(max_length=512)
sourcelink = models.URLField("Source link", max_length=512, blank=True)
date = models.DateTimeField("Date added", auto_now_add=True)
languages = models.ManyToManyField(Language)
visible = models.BooleanField(default=False)
publish_email = models.BooleanField("Publish e-mail", default=False)
featured = models.BooleanField(default=False)
featured_order = models.IntegerField("Order (for featured sites)", blank=True, null=True)
featured_reason = models.TextField("Reason (for featured sites)", max_length=100, blank=True)
@@ -60,26 +58,9 @@ def clickable_sourcelink(self):
def description_formatted(self):
return mark_safe(escape(self.description).replace('\n\n', '<p>').replace('\n', '<br>'))

def author_link(self):
if self.publish_email:
return format_html('<a href="mailto:{0}">{1}</a>', self.email,
self.author)
else:
return self.author

def author_link_always(self):
return format_html('<a href="mailto:{0}">{1}</a>', self.email,
self.author)

clickable_url.short_description = 'URL'
clickable_url = property(clickable_url)

author_link.short_description = 'Author'
author_link = property(author_link)

author_link_always.short_description = 'Author'
author_link_always = property(author_link_always)

def __str__(self):
"""String representation of a site."""
return self.title
@@ -101,10 +101,8 @@ def add(request):
site.title = form.cleaned_data['title']
site.url = form.cleaned_data['url']
site.author = form.cleaned_data['author']
site.email = form.cleaned_data['email']
site.description = form.cleaned_data['description']
site.sourcelink = form.cleaned_data['sourcelink']
site.publish_email = form.cleaned_data['publish_email']
site.save()
for lang in form.cleaned_data['languages']:
try:
@@ -122,9 +120,9 @@ def add(request):
try:
send_mail(
"Nikola Users addition request for {0}".format(site.url),
'{0} <{1}> has requested addition of "{2}" <{3}> to the Nikola Users site.\n'
'{0} has requested addition of "{1}" <{2}> to the Nikola Users site.\n'
'Please visit the admin panel to accept or reject it: https://users.getnikola.com/admin/'.format(
site.author, site.email, site.title, site.url),
site.author, site.title, site.url),
'nikola-users@chriswarrick.com', ['nikola-users@chriswarrick.com'], fail_silently=False)
context['email_succeeded'] = True
except Exception:
@@ -4,7 +4,7 @@
{% if email_succeeded %}
<p>Administrators were informed of your request. Your site will be added within 48 hours.</p>
{% else %}
<p class="text-warning">WARNING: Administrators were not informed of your request because sending e-mail failed. Please report this to <a href="https://getnikola.com/contact.html">the Nikola team</a> (preferably on Twitter, or personally to Chris through e-mail)</p>
<p class="text-warning">WARNING: Administrators were not informed of your request because sending e-mail failed. Please report this to <a href="https://getnikola.com/contact.html">the Nikola team</a> (preferably on Twitter, or personally to Chris Warrick through e-mail)</p>
{% endif %}

<p>The administrators reserve the right to alter the information, or reject your site altogether.</p>
@@ -15,10 +15,6 @@
<dd>{{ site.title }}</dd>
<dt>Author</dt>
<dd>{{ site.author }}</dd>
<dt>Email</dt>
<dd>{{ site.email }}</dd>
<dt>Publish email</dt>
<dd>{% if site.publish_email %}yes{% else %}no{% endif %}</dd>
<dt>URL</dt>
<dd>{{ site.clickable_url }}</dd>
<dt>Description</dt>
@@ -20,14 +20,6 @@
boat.</span>
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-2" for="inputEmail">E-mail address</label>
<div class="col-lg-5">
<input type="email" class="form-control" name="email" id="inputEmail" placeholder="E-mail address"
required maxlength="100">
<span class="help-block">Will not be published if you do not want to.</span>
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-2" for="inputURL">URL</label>
<div class="col-lg-5">
@@ -73,9 +65,6 @@
<label class="checkbox">
<input name="tos" type="checkbox" required> I agree to the <a href="/tos/">Terms of Service and Privacy Policy</a>.
</label>
<label class="checkbox">
<input name="publish_email" type="checkbox"> I want my e-mail address visible publicly.
</label>
<button type="submit" class="btn btn-primary">Request addition</button>
</div>
</div>
@@ -1,24 +1,45 @@
{% extends "base.html" %}
{% block content %}
<div>
<p>This feature has been disabled. If you want to test a site, use the following Python program:</p>
<pre class="code python"><a name="rest_code_871104a093764d779132a78f4d157c8d-1"></a><span class="kn">import</span> <span class="nn">requests</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-2"></a>
<a name="rest_code_871104a093764d779132a78f4d157c8d-3"></a><span class="n">url</span> <span class="o">=</span> <span class="nb">input</span><span class="p">(</span><span class="s2">"URL to check: "</span><span class="p">)</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-4"></a><span class="k">if</span> <span class="ow">not</span> <span class="n">url</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s1">'/rss.xml'</span><span class="p">):</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-5"></a> <span class="n">url</span> <span class="o">+=</span> <span class="s2">"/rss.xml"</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-6"></a><span class="n">r</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">url</span><span class="p">)</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-7"></a><span class="n">patterns</span> <span class="o">=</span> <span class="p">[(</span><span class="n">b</span><span class="s1">'&lt;generator&gt;https://getnikola.com/&lt;/generator&gt;'</span><span class="p">,</span> <span class="s1">'Nikola v7.6.1+'</span><span class="p">),</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-8"></a> <span class="p">(</span><span class="n">b</span><span class="s1">'&lt;generator&gt;http://getnikola.com/&lt;/generator&gt;'</span><span class="p">,</span> <span class="s1">'Nikola v7.0.0-v7.6.0'</span><span class="p">),</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-9"></a> <span class="p">(</span><span class="n">b</span><span class="s1">'&lt;generator&gt;Nikola &lt;http://getnikola.com/&gt;&lt;/generator&gt;'</span><span class="p">,</span> <span class="s1">'Nikola v6.3.0-v6.4.0'</span><span class="p">),</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-10"></a> <span class="p">(</span><span class="n">b</span><span class="s1">'&lt;generator&gt;nikola&lt;/generator&gt;'</span><span class="p">,</span> <span class="s1">'Nikola v6.2.1 or older'</span><span class="p">]</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-11"></a><span class="n">result</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-12"></a><span class="k">for</span> <span class="n">pattern</span><span class="p">,</span> <span class="n">description</span> <span class="ow">in</span> <span class="n">patterns</span><span class="p">:</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-13"></a> <span class="k">if</span> <span class="n">pattern</span> <span class="ow">in</span> <span class="n">r</span><span class="o">.</span><span class="n">content</span><span class="p">:</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-14"></a> <span class="k">print</span><span class="p">(</span><span class="n">description</span><span class="p">)</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-15"></a> <span class="nb">exit</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-16"></a><span class="k">print</span><span class="p">(</span><span class="s2">"Not a Nikola site"</span><span class="p">)</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-17"></a><span class="nb">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
</pre>
<p>This feature has been disabled. If you want to test a site, use the following Python script:</p>
<table class="codetable"><tr>
<td class="linenos"><div class="linenodiv"><pre><a href="#listingscheckerpy-1"> 1</a>
<a href="#listingscheckerpy-2"> 2</a>
<a href="#listingscheckerpy-3"> 3</a>
<a href="#listingscheckerpy-4"> 4</a>
<a href="#listingscheckerpy-5"> 5</a>
<a href="#listingscheckerpy-6"> 6</a>
<a href="#listingscheckerpy-7"> 7</a>
<a href="#listingscheckerpy-8"> 8</a>
<a href="#listingscheckerpy-9"> 9</a>
<a href="#listingscheckerpy-10">10</a>
<a href="#listingscheckerpy-11">11</a>
<a href="#listingscheckerpy-12">12</a>
<a href="#listingscheckerpy-13">13</a>
<a href="#listingscheckerpy-14">14</a>
<a href="#listingscheckerpy-15">15</a>
<a href="#listingscheckerpy-16">16</a>
<a href="#listingscheckerpy-17">17</a>
<a href="#listingscheckerpy-18">18</a></pre></div></td>
<td class="code"><pre class="code literal-block"><a name="listingscheckerpy-1"></a><span class="kn">import</span> <span class="nn">requests</span>
<a name="listingscheckerpy-2"></a>
<a name="listingscheckerpy-3"></a><span class="n">url</span> <span class="o">=</span> <span class="nb">input</span><span class="p">(</span><span class="s2">"URL to check: "</span><span class="p">)</span>
<a name="listingscheckerpy-4"></a><span class="k">if</span> <span class="ow">not</span> <span class="n">url</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s1">'/rss.xml'</span><span class="p">):</span>
<a name="listingscheckerpy-5"></a> <span class="n">url</span> <span class="o">+=</span> <span class="s2">"/rss.xml"</span>
<a name="listingscheckerpy-6"></a><span class="n">r</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">url</span><span class="p">)</span>
<a name="listingscheckerpy-7"></a><span class="n">patterns</span> <span class="o">=</span> <span class="p">[(</span><span class="sa">b</span><span class="s1">'&lt;generator&gt;https://getnikola.com/&lt;/generator&gt;'</span><span class="p">,</span> <span class="s1">'Nikola v7.8.2+'</span><span class="p">),</span>
<a name="listingscheckerpy-8"></a> <span class="p">(</span><span class="sa">b</span><span class="s1">'&lt;generator&gt;https://getnikola.com/&lt;/generator&gt;'</span><span class="p">,</span> <span class="s1">'Nikola v7.6.1-v7.8.1'</span><span class="p">),</span>
<a name="listingscheckerpy-9"></a> <span class="p">(</span><span class="sa">b</span><span class="s1">'&lt;generator&gt;http://getnikola.com/&lt;/generator&gt;'</span><span class="p">,</span> <span class="s1">'Nikola v7.0.0-v7.6.0'</span><span class="p">),</span>
<a name="listingscheckerpy-10"></a> <span class="p">(</span><span class="sa">b</span><span class="s1">'&lt;generator&gt;Nikola &lt;http://getnikola.com/&gt;&lt;/generator&gt;'</span><span class="p">,</span> <span class="s1">'Nikola v6.3.0-v6.4.0'</span><span class="p">),</span>
<a name="listingscheckerpy-11"></a> <span class="p">(</span><span class="sa">b</span><span class="s1">'&lt;generator&gt;nikola&lt;/generator&gt;'</span><span class="p">,</span> <span class="s1">'Nikola v6.2.1 or older'</span><span class="p">)]</span>
<a name="listingscheckerpy-12"></a><span class="n">result</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
<a name="listingscheckerpy-13"></a><span class="k">for</span> <span class="n">pattern</span><span class="p">,</span> <span class="n">description</span> <span class="ow">in</span> <span class="n">patterns</span><span class="p">:</span>
<a name="listingscheckerpy-14"></a> <span class="k">if</span> <span class="n">pattern</span> <span class="ow">in</span> <span class="n">r</span><span class="o">.</span><span class="n">content</span><span class="p">:</span>
<a name="listingscheckerpy-15"></a> <span class="k">print</span><span class="p">(</span><span class="n">description</span><span class="p">)</span>
<a name="listingscheckerpy-16"></a> <span class="nb">exit</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
<a name="listingscheckerpy-17"></a><span class="k">print</span><span class="p">(</span><span class="s2">"Not a Nikola site"</span><span class="p">)</span>
<a name="listingscheckerpy-18"></a><span class="nb">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
</pre></td>
</tr></table>
</div>
{% endblock %}
@@ -3,8 +3,7 @@
<p>
In order to {{ page }} your site’s entry, simply send an e-mail to <a
href="mailto:users@getnikola.com">users@getnikola.com</a>
— preferably using the same e-mail address you did when you requested
addition. {% if page == "remove" %}Including a reason is recommended.{% endif %}
— make sure to prove you own the site. {% if page == "remove" %}Including a reason is recommended.{% endif %}
</p>

<p>We require using e-mail, because someone might make a fraudulent request.
@@ -19,7 +19,7 @@
<header class="caption" style="margin: 0; clear: both;">
<h4 class="pagelink">{{ site.link }}<br>
<small class="metadata">
<p class="byline author vcard">by {{ site.author_link }}</p>
<p class="byline author vcard">by {{ site.author }}</p>
{% if site.sourcelink %}
<p class="sourceline">{{ site.clickable_sourcelink }}</p>
{% endif %}
@@ -54,7 +54,7 @@ <h4 class="pagelink">{{ site.link }}<br>
<div class="caption" style="margin: 0; clear: both;">
<h4 class="pagelink">{{ site.link }}<br>
<small class="metadata">
<p class="byline author vcard">by {{ site.author_link }}</p>
<p class="byline author vcard">by {{ site.author }}</p>
{% if site.sourcelink %}
<p class="sourceline">{{ site.clickable_sourcelink }}</p>
{% endif %}
@@ -14,8 +14,6 @@ <h2>General service terms</h2>
scripts are not allowed to use the Service.</li>
<li>Roberto Alsina and Chris Warrick promise not to sell or abuse any of
the details you entered while registering with the Service.</li>
<li>You agree that you may receive occasional emails related to the
Service. No marketing mail will be sold.</li>
</ol>

<h2>Content</h2>

0 comments on commit 3aeb661

Please sign in to comment.
You can’t perform that action at this time.