Compare commits
13 Commits
admin-impr
...
master
Author | SHA1 | Date |
---|---|---|
vilmibm | afc5d30ed8 | |
vilmibm | 8d04787277 | |
vilmibm | be2975ad62 | |
vilmibm | 0f078f86fd | |
vilmibm | 90dca0274a | |
vilmibm | 158bdcff5f | |
vilmibm | 77d728a153 | |
vilmibm | 2385446e74 | |
vilmibm | 5220d9bfad | |
vilmibm | 4e3977edd2 | |
vilmibm | 2354695401 | |
vilmibm | de07b42082 | |
Nate Smith | 3d12a5bfd4 |
|
@ -9,4 +9,4 @@ VENV=/town/venvs/ttadmin
|
||||||
source $VENV/bin/activate
|
source $VENV/bin/activate
|
||||||
export DJANGO_SETTINGS_MODULE=settings_live
|
export DJANGO_SETTINGS_MODULE=settings_live
|
||||||
cd $APP_ROOT
|
cd $APP_ROOT
|
||||||
gunicorn -b0.0.0.0:$PORT ttadmin.wsgi
|
gunicorn -t120 -b0.0.0.0:$PORT ttadmin.wsgi
|
||||||
|
|
4
setup.py
4
setup.py
|
@ -15,9 +15,9 @@ setup(
|
||||||
'License :: OSI Approved :: Affero GNU General Public License v3 (AGPLv3)',
|
'License :: OSI Approved :: Affero GNU General Public License v3 (AGPLv3)',
|
||||||
],
|
],
|
||||||
packages=['ttadmin'],
|
packages=['ttadmin'],
|
||||||
install_requires = ['Django==1.10.2',
|
install_requires = ['Django==1.11.29',
|
||||||
'sshpubkeys==2.2.0',
|
'sshpubkeys==2.2.0',
|
||||||
'psycopg2==2.7.6.1',
|
'psycopg2-binary==2.8.5',
|
||||||
'gunicorn==19.6.0',
|
'gunicorn==19.6.0',
|
||||||
'Mastodon.py==1.4.5',
|
'Mastodon.py==1.4.5',
|
||||||
'tweepy==3.7.0'],
|
'tweepy==3.7.0'],
|
||||||
|
|
|
@ -20,15 +20,15 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>tilde.town guestbook</h1>
|
<h1>tilde.town guestbook</h1>
|
||||||
|
<p><em>don't try to post urls. it won't work.</em></p>
|
||||||
<marquee>~*~*~*~*say hello*~*~*~*~</marquee>
|
<marquee>~*~*~*~*say hello*~*~*~*~</marquee>
|
||||||
<!-- <form class="tilde" action="{% url 'guestbook:guestbook' %}" method="post">
|
<form class="tilde" action="{% url 'guestbook:guestbook' %}" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<table>
|
<table>
|
||||||
{{form.as_table}}
|
{{form.as_table}}
|
||||||
</table>
|
</table>
|
||||||
<input type="submit" value="sign" >
|
<input type="submit" value="sign" >
|
||||||
</form>
|
</form>
|
||||||
-->
|
|
||||||
|
|
||||||
{% for m in messages %}
|
{% for m in messages %}
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import re
|
||||||
|
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
from django.views.generic.edit import FormView
|
from django.views.generic.edit import FormView
|
||||||
|
@ -5,6 +7,8 @@ from django.views.generic.edit import FormView
|
||||||
from .forms import GuestbookForm
|
from .forms import GuestbookForm
|
||||||
from .models import GuestbookMessage
|
from .models import GuestbookMessage
|
||||||
|
|
||||||
|
SUSPICIOUS_RE = re.compile(r'https?://')
|
||||||
|
|
||||||
|
|
||||||
class GuestbookView(FormView):
|
class GuestbookView(FormView):
|
||||||
form_class = GuestbookForm
|
form_class = GuestbookForm
|
||||||
|
@ -17,5 +21,7 @@ class GuestbookView(FormView):
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
del form.cleaned_data['captcha']
|
del form.cleaned_data['captcha']
|
||||||
|
if SUSPICIOUS_RE.search(form.cleaned_data['msg']) != None:
|
||||||
|
return redirect('guestbook:guestbook')
|
||||||
t = GuestbookMessage.objects.create(**form.cleaned_data)
|
t = GuestbookMessage.objects.create(**form.cleaned_data)
|
||||||
return redirect('guestbook:guestbook')
|
return redirect('guestbook:guestbook')
|
||||||
|
|
|
@ -2,8 +2,8 @@ from django.conf.urls import url, include
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^help/', include('help.urls')),
|
# url(r'^help/', include('help.urls')),
|
||||||
url(r'^users/', include('users.urls')),
|
url(r'^users/', include('users.urls')),
|
||||||
url(r'^guestbook/', include('guestbook.urls')),
|
# url(r'^guestbook/', include('guestbook.urls')),
|
||||||
url(r'^admin/', admin.site.urls),
|
url(r'^admin/', admin.site.urls),
|
||||||
]
|
]
|
||||||
|
|
|
@ -11,7 +11,7 @@ class PubkeyInline(admin.TabularInline):
|
||||||
|
|
||||||
def bulk_accept(madmin, req, qs):
|
def bulk_accept(madmin, req, qs):
|
||||||
for townie in qs:
|
for townie in qs:
|
||||||
townie.state = 'accepted'
|
townie.state = Townie.ACCEPTED
|
||||||
townie.save()
|
townie.save()
|
||||||
post_users_to_social(qs)
|
post_users_to_social(qs)
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ bulk_accept.short_description = 'mark selected townies as accepted'
|
||||||
|
|
||||||
def bulk_reject(madmin, req, qs):
|
def bulk_reject(madmin, req, qs):
|
||||||
for townie in qs:
|
for townie in qs:
|
||||||
townie.state = 'rejected'
|
townie.state = Townie.REJECTED
|
||||||
townie.save()
|
townie.save()
|
||||||
|
|
||||||
bulk_reject.short_description = 'mark selected townies as rejected'
|
bulk_reject.short_description = 'mark selected townies as rejected'
|
||||||
|
|
|
@ -12,9 +12,9 @@ submission_throttle = {}
|
||||||
throttle_submission = throttler(submission_throttle)
|
throttle_submission = throttler(submission_throttle)
|
||||||
|
|
||||||
|
|
||||||
USERNAME_RE = re.compile(r'[a-z][a-z0-9_]+')
|
USERNAME_RE = re.compile(r'^[a-z][a-z0-9_]+$')
|
||||||
USERNAME_MIN_LENGTH = 3
|
USERNAME_MIN_LENGTH = 2
|
||||||
DISPLAY_NAME_RE = re.compile(r"[a-zA-Z0-9_\-']+")
|
DISPLAY_NAME_RE = re.compile(r"^[a-zA-Z0-9_\-']+$")
|
||||||
DISPLAY_MIN_LENGTH = 2
|
DISPLAY_MIN_LENGTH = 2
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ def set_state(apps, _):
|
||||||
Townie = apps.get_model('users', 'Townie')
|
Townie = apps.get_model('users', 'Townie')
|
||||||
for townie in Townie.objects.all():
|
for townie in Townie.objects.all():
|
||||||
if townie.reviewed:
|
if townie.reviewed:
|
||||||
townie.state = Townie.ACCEPTED
|
townie.state = '2_accepted'
|
||||||
|
|
||||||
townie.save()
|
townie.save()
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ SSH_TYPE_CHOICES = (
|
||||||
('ssh-rsa', 'ssh-rsa',),
|
('ssh-rsa', 'ssh-rsa',),
|
||||||
('ssh-dss', 'ssh-dss',),
|
('ssh-dss', 'ssh-dss',),
|
||||||
('ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp256'),
|
('ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp256'),
|
||||||
|
('ssh-ed25519', 'ssh-ed25519'),
|
||||||
)
|
)
|
||||||
|
|
||||||
DEFAULT_INDEX_PATH = '/etc/skel/public_html/index.html'
|
DEFAULT_INDEX_PATH = '/etc/skel/public_html/index.html'
|
||||||
|
@ -78,6 +79,13 @@ class Townie(User):
|
||||||
def home(self):
|
def home(self):
|
||||||
return os.path.join('/home', self.username)
|
return os.path.join('/home', self.username)
|
||||||
|
|
||||||
|
def generate_gift(self):
|
||||||
|
command = '/town/bin/generate_welcome_present.sh'
|
||||||
|
error = _guarded_run(['sudo', command, self.username])
|
||||||
|
if error:
|
||||||
|
logger.error(error)
|
||||||
|
return
|
||||||
|
|
||||||
def send_welcome_email(self):
|
def send_welcome_email(self):
|
||||||
welcome_tmpl = get_template('users/welcome_email.txt')
|
welcome_tmpl = get_template('users/welcome_email.txt')
|
||||||
context = {
|
context = {
|
||||||
|
@ -246,9 +254,15 @@ def on_townie_pre_save(sender, instance, **kwargs):
|
||||||
# See if we need to create the user on disk.
|
# See if we need to create the user on disk.
|
||||||
if existing.unreviewed and instance.accepted:
|
if existing.unreviewed and instance.accepted:
|
||||||
logger.info('Creating user {} on disk.'.format(instance.username))
|
logger.info('Creating user {} on disk.'.format(instance.username))
|
||||||
instance.create_on_disk()
|
try:
|
||||||
instance.send_welcome_email()
|
instance.create_on_disk()
|
||||||
instance.write_authorized_keys()
|
instance.write_authorized_keys()
|
||||||
|
except Exception as e:
|
||||||
|
logger.error('Failed syncing user {} to disk: {}'.format(instance.username, e))
|
||||||
|
else:
|
||||||
|
instance.send_welcome_email()
|
||||||
|
instance.generate_gift()
|
||||||
|
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
# This user state transition is currently undefined. In the future, we can check for things
|
# This user state transition is currently undefined. In the future, we can check for things
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
<li><a href="https://tilde.town/~kc/blackout/">black out</a></li>
|
<li><a href="https://tilde.town/~kc/blackout/">black out</a></li>
|
||||||
<li><a href="https://tilde.town/~subtransience/machinecode/index.html">the machine room</a></li>
|
<li><a href="https://tilde.town/~subtransience/machinecode/index.html">the machine room</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<h2>or a <a href="https://tilde.town/cgi/random">random page</a></h2>
|
<h2>or a <a href="https://cgi.tilde.town/users/random">random page</a></h2>
|
||||||
</td>
|
</td>
|
||||||
<td style="padding:1em">
|
<td style="padding:1em">
|
||||||
<a href="http://giphy.com/gifs/cyndipop-golden-girls-bea-arthur-ToMjGpK80QLT7KLWPLO">
|
<a href="http://giphy.com/gifs/cyndipop-golden-girls-bea-arthur-ToMjGpK80QLT7KLWPLO">
|
||||||
|
|
|
@ -12,10 +12,17 @@ from django.views.generic.edit import FormView
|
||||||
from .forms import TownieForm
|
from .forms import TownieForm
|
||||||
from .models import Townie, Pubkey
|
from .models import Townie, Pubkey
|
||||||
|
|
||||||
|
SIGNUPS_ENABLED = True
|
||||||
|
|
||||||
class SignupView(FormView):
|
class SignupView(FormView):
|
||||||
form_class = TownieForm
|
form_class = TownieForm
|
||||||
template_name = 'users/signup.html'
|
template_name = 'users/signup.html'
|
||||||
extra_context = {"signups_enabled": False}
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
ctx = super().get_context_data(**kwargs)
|
||||||
|
ctx['signups_enabled'] = SIGNUPS_ENABLED
|
||||||
|
return ctx
|
||||||
|
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
|
|
Loading…
Reference in New Issue