orionblastar / K666

K666 is forum discussion software, this is an attempt to write the Free version FreeK666 without violating copyright
http://k666.kr5ddit.com
MIT License
5 stars 0 forks source link

Add User Signup #8

Closed procrasti closed 8 years ago

procrasti commented 8 years ago

Depends: https://github.com/orionblastar/K666/issues/6 Branch: signup

We're going to use django-allauth (https://github.com/pennersr/django-allauth) to allow our users to login and signup, because it has many advantages over the the admin/login, and admin doesn't give us user registration anyway.

Take a quick read through of the docs: http://django-allauth.readthedocs.io/en/latest/

Pretty much do everything on the install page, but don't configure any social apps yet... maybe we'll do google later...

Instead of doing pip install django-allauth, update the setup.py to include django-allauth as a depency.

Now change the links on your static page to /accounts/login and /accounts/logout.

procrasti commented 8 years ago

I'll assign this to you after you've closed the dependent issues and started on the fragments (issue #13).

We'll get a lot out of this!

procrasti commented 8 years ago

Alright... Have a go at this... create the branch from master... read the allauth docs...

Don't try to add any social auth stuff... just simple signup!

Remember release early / often... so I can see any progress... help you along.

procrasti commented 8 years ago

To make this easier on you, I've already updated the commonlinks_fragment in master... and you only have to change setup.py, k666/settings.py and k666/urls.py.

diff --git a/setup.py b/setup.py
index bfaa8a3..d17db1d 100644
--- a/setup.py
+++ b/setup.py
@@ -8,5 +8,6 @@ setup(
        name="k666",
        install_requires=[
                'Django',
+               'django-allauth',
        ],
 )
--- a/k666/settings.py
+++ b/k666/settings.py
@@ -32,6 +32,10 @@ ALLOWED_HOSTS = []

 INSTALLED_APPS = (
     'freek666',
+    'django.contrib.sites',
+    'allauth',
+    'allauth.account',
+    'allauth.socialaccount',
     'django.contrib.admin',
     'django.contrib.auth',
     'django.contrib.contenttypes',
@@ -101,3 +105,6 @@ USE_TZ = True
 # https://docs.djangoproject.com/en/1.8/howto/static-files/

 STATIC_URL = '/static/'
+SITE_ID = 1
+
+LOGIN_REDIRECT_URL = '/index.html'
--- a/k666/urls.py
+++ b/k666/urls.py
@@ -19,4 +19,5 @@ from django.contrib import admin
 urlpatterns = [
     url(r'^admin/', include(admin.site.urls)),
     url(r'^', include('freek666.urls')),
+    url(r'^accounts/', include('allauth.urls')),
 ]
orionblastar commented 8 years ago

I got an error running k666-env:

Installed /home/norman/k6allauth/env/lib/python2.7/site-packages/django_allauth-0.25.2-py2.7.egg error: Could not find required distribution Django Traceback (most recent call last): File "./manage.py", line 8, in from django.core.management import execute_from_command_line ImportError: No module named django.core.management Traceback (most recent call last): File "./manage.py", line 8, in from django.core.management import execute_from_command_line ImportError: No module named django.core.management Traceback (most recent call last): File "./manage.py", line 8, in from django.core.management import execute_from_command_line ImportError: No module named django.core.management (env)norman@Lazarus0 ~/k6allauth $ python manage.py migrate Traceback (most recent call last): File "manage.py", line 8, in from django.core.management import execute_from_command_line ImportError: No module named django.core.management

I checked in the branch allauth with my changes. Not sure what I did wrong.

orionblastar commented 8 years ago

Wait a minute, I think I forgot to add in something for allauth.

orionblastar commented 8 years ago

I had to change something in the settings.py file, apparently in the example they had three periods in the structure of text and I copy pasted it in. After removing the three periods it seems like it runs now. Has a login and signup screen but I haven't tested them yet.

procrasti commented 8 years ago

Well, give it a go... test it!

procrasti commented 8 years ago

Nope... I just git checkout allauth, and I get the no module named django.core.management... will look into it, but seems like your settings isn't working?

procrasti commented 8 years ago

It seems to try to install django-allauth before it has installed Django... so django-allauth can't find the django libraries it needs to run to install... but you would think that would be a dependency of django-allauth... this is a bit of a worry, and why haven't I seen that before? Otherwise it appears to work (run k666-env again...) but we try and sort this.

procrasti commented 8 years ago

Reversing the order in setup.py seemed to fix it... odd fix... not sure if that's the official way to do it... we'll see!

Otherwise this seems to work!

So, onto messages next!

procrasti commented 8 years ago

It's merged into master now, you can close this issue, and remove the branch (soonish) if you want... and onto getting messaging working.

Don't forget to signup yourself, and I'll add you as a superadmin.