Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions oshc/main/regbackend.py

This file was deleted.

7 changes: 0 additions & 7 deletions oshc/main/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@
<li><a href="https://github.com/OpenSourceHelpCommunity" target="_blank">Resources</a></li>
<li><a href="mailto:opensourcehelpcommunity@gmail.com" target="_blank">Contact</a></li>
<li><a href="https://opensourcehelp.herokuapp.com/" target="_blank">Join Us!</a></li>
{% if user.is_authenticated %}
<li><a href="#!">Hey {{ user.username }}!</a></li>
<li><a href="{% url 'auth_logout' %}">Logout</a></li>
{% else %}
<li><a href="{% url 'auth_login' %}" target="_blank">Sign In</a></li>
<li><a href="{% url 'registration_register' %}" target="_blank">Sign Up</a></li>
{% endif %}
</ul>
</div>
</div>
Expand Down
35 changes: 0 additions & 35 deletions oshc/main/templates/registration/login.html

This file was deleted.

9 changes: 0 additions & 9 deletions oshc/main/templates/registration/logout.html

This file was deleted.

10 changes: 0 additions & 10 deletions oshc/main/templates/registration/password_reset_complete.html

This file was deleted.

16 changes: 0 additions & 16 deletions oshc/main/templates/registration/password_reset_confirm.html

This file was deleted.

9 changes: 0 additions & 9 deletions oshc/main/templates/registration/password_reset_done.html

This file was deleted.

5 changes: 0 additions & 5 deletions oshc/main/templates/registration/password_reset_email.html

This file was deleted.

25 changes: 0 additions & 25 deletions oshc/main/templates/registration/password_reset_form.html

This file was deleted.

9 changes: 0 additions & 9 deletions oshc/main/templates/registration/registration_closed.html

This file was deleted.

9 changes: 0 additions & 9 deletions oshc/main/templates/registration/registration_complete.html

This file was deleted.

45 changes: 0 additions & 45 deletions oshc/main/templates/registration/registration_form.html

This file was deleted.

56 changes: 0 additions & 56 deletions oshc/main/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,13 @@
from django.test import SimpleTestCase, TestCase
from django.urls import reverse

from .regbackend import EmailLoginBackend


class EmailLoginBackendTests(TestCase):

def setUp(self):
self.credentials = {
'username': 'testuser',
'email': 'testuser@email.com',
'password': 'secret'}
self.user = User.objects.create_user(**self.credentials)

def test_valid_username_login(self):
response = self.client.login(username=self.credentials['username'],
password=self.credentials['password'])
self.assertTrue(response)

def test_invalid_username_login(self):
response = self.client.login(username='invalid_username',
password=self.credentials['password'])
self.assertFalse(response)

def test_valid_email_login(self):
response = self.client.login(username=self.credentials['email'],
password=self.credentials['password'])
self.assertTrue(response)

def test_invalid_email_login(self):
response = self.client.login(username='invalid_email',
password=self.credentials['password'])
self.assertFalse(response)

def test_invalid_password_login(self):
response = self.client.login(username=self.credentials['email'],
password='incorrect_password')
self.assertFalse(response)

def test_valid_get_user(self):
backend = EmailLoginBackend()
returned_user = backend.get_user(self.user.id)
self.assertEqual(returned_user.id, self.user.id)

def test_invalid_get_user(self):
backend = EmailLoginBackend()
# The database has only one user. User with id=10 doesn't exists
returned_user = backend.get_user(user_id=10)
self.assertIsNone(returned_user)


class HomeViewTests(TestCase):

def test_get_request(self):
response = self.client.get(reverse("home"))
self.assertEqual(response.status_code, 200)

def test_login_accessible(self):
response = self.client.get(reverse('auth_login'))
self.assertEqual(response.status_code, 200)

def test_signup_accessible(self):
response = self.client.get(reverse('registration_register'))
self.assertEqual(response.status_code, 200)


class RequestSessionViewTests(SimpleTestCase):

Expand Down
32 changes: 3 additions & 29 deletions oshc/oshc/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
import dj_database_url

BASE_DIR = os.path.dirname(os.path.dirname(__file__))

Expand All @@ -27,9 +26,9 @@

# Tuple of people who get error notifications
ADMINS = [
('Tapasweni Pathak','tapaswenipathak@gmail.com'),
('Nikhita Raghunath','nikitaraghunath@gmail.com'),
('Ibrahim Jarif','jarifibrahim@gmail.com'),
('Tapasweni Pathak', 'tapaswenipathak@gmail.com'),
('Nikhita Raghunath', 'nikitaraghunath@gmail.com'),
('Ibrahim Jarif', 'jarifibrahim@gmail.com'),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vaibhavsingh97 Please remove these spaces

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anubhakushwaha According to PEP 8, we should have spaces. If you want i can remove.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vaibhavsingh97 Ooh that's interesting, we would love to learn more,Is this the place? https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

('Amar Prakash Pandey', 'amar.om1994@gmail.com')
]

Expand All @@ -43,7 +42,6 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'registration',
)

MIDDLEWARE_CLASSES = (
Expand Down Expand Up @@ -76,11 +74,6 @@
},
]

AUTHENTICATION_BACKENDS = (
'main.regbackend.EmailLoginBackend',
'django.contrib.auth.backends.ModelBackend'
)

# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases

Expand All @@ -91,25 +84,6 @@
}
}

# Get DATABASE_URL environment variable and update default DATABASE settings
db_from_env = dj_database_url.config()
DATABASES['default'].update(db_from_env)

# If True, users can register
REGISTRATION_OPEN = True
# One-week activation window; you may, of course, use a different value.
ACCOUNT_ACTIVATION_DAYS = 7
# If True, the user will be automatically logged in.
REGISTRATION_AUTO_LOGIN = True
# If true, email will be sent as HTML
# REGISTRATION_EMAIL_HTML = True
# The page you want users to arrive at after they successfully log in
# The page users are directed to if they are not logged in,
LOGIN_REDIRECT_URL = 'home'
# and are trying to access pages requiring authentication
LOGIN_URL = '/accounts/login/'
LOGOUT_REDIRECT_URL = 'home'

# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/

Expand Down
1 change: 0 additions & 1 deletion oshc/oshc/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'', include('main.urls')),
url(r'^accounts/', include('registration.backends.simple.urls')),
]