Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/remove-core-deps'
Browse files Browse the repository at this point in the history
  • Loading branch information
seocam committed Jul 2, 2015
2 parents e2a52f5 + e2e2afd commit a2e34e5
Show file tree
Hide file tree
Showing 67 changed files with 125 additions and 1,686 deletions.
7 changes: 0 additions & 7 deletions colab/accounts/auth.py

This file was deleted.

38 changes: 0 additions & 38 deletions colab/accounts/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
from django.utils.translation import ugettext_lazy as _
from django.utils.safestring import mark_safe

from conversejs.models import XMPPAccount


from .utils.validators import validate_social_account
from .utils import mailman
Expand Down Expand Up @@ -152,42 +150,6 @@ class ListsForm(forms.Form):
choices=LISTS_NAMES)


class ChangeXMPPPasswordForm(forms.ModelForm):
password1 = forms.CharField(label=_("Password"),
widget=forms.PasswordInput)
password2 = forms.CharField(label=_("Password confirmation"),
widget=forms.PasswordInput,
help_text=_(("Enter the same password as above"
", for verification.")))

class Meta:
model = XMPPAccount
fields = ('password1', 'password2')

def __init__(self, *args, **kwargs):
super(ChangeXMPPPasswordForm, self).__init__(*args, **kwargs)

for field_name, field in self.fields.items():
# Adds form-control class to all form fields
field.widget.attrs.update({'class': 'form-control'})

def clean_password2(self):
password1 = self.cleaned_data.get("password1")
password2 = self.cleaned_data.get("password2")
if password1 and password2 and password1 != password2:
raise forms.ValidationError(
_("Password mismatch"),
code='password_mismatch',
)
return password2

def save(self, commit=True):
self.instance.password = self.cleaned_data['password2']
if commit:
self.instance.save()
return self.instance


class UserCreationForm(UserForm):
"""
A form that creates a user, with no privileges, from the given username and
Expand Down
24 changes: 0 additions & 24 deletions colab/accounts/middleware.py

This file was deleted.

7 changes: 0 additions & 7 deletions colab/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ class User(AbstractUser):

objects = ColabUserManager()

def check_password(self, raw_password):

if self.xmpp.exists() and raw_password == self.xmpp.first().password:
return True

return super(User, self).check_password(raw_password)

def get_absolute_url(self):
return reverse('user_profile', kwargs={'username': self.username})

Expand Down
32 changes: 0 additions & 32 deletions colab/accounts/search_indexes.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-

from haystack import indexes
# from django.db.models import Count

from colab.badger.utils import get_users_counters
from .models import User


Expand All @@ -26,30 +23,13 @@ class UserIndex(indexes.SearchIndex, indexes.Indexable):
stored=False)
webpage = indexes.CharField(model_attr='webpage', null=True, stored=False)
message_count = indexes.IntegerField(stored=False)
# changeset_count = indexes.IntegerField(stored=False)
# ticket_count = indexes.IntegerField(stored=False)
# wiki_count = indexes.IntegerField(stored=False)
contribution_count = indexes.IntegerField(stored=False)

def get_model(self):
return User

@property
def badge_counters(self):
if not hasattr(self, '_badge_counters'):
self._badge_counters = get_users_counters()
return self._badge_counters

def prepare(self, obj):
prepared_data = super(UserIndex, self).prepare(obj)

prepared_data['contribution_count'] = sum((
self.prepared_data['message_count'],
# self.prepared_data['changeset_count'],
# self.prepared_data['ticket_count'],
# self.prepared_data['wiki_count']
))

return prepared_data

def prepare_description(self, obj):
Expand All @@ -63,17 +43,5 @@ def prepare_icon_name(self, obj):
def prepare_type(self, obj):
return u'user'

def prepare_message_count(self, obj):
return self.badge_counters[obj.username]['messages']

# def prepare_changeset_count(self, obj):
# return self.badge_counters[obj.username]['revisions']

# def prepare_ticket_count(self, obj):
# return self.badge_counters[obj.username]['tickets']

# def prepare_wiki_count(self, obj):
# return self.badge_counters[obj.username]['wikis']

def index_queryset(self, using=None):
return self.get_model().objects.filter(is_active=True)
21 changes: 0 additions & 21 deletions colab/accounts/templates/accounts/change_password.html

This file was deleted.

12 changes: 0 additions & 12 deletions colab/accounts/templates/accounts/login.html

This file was deleted.

37 changes: 8 additions & 29 deletions colab/accounts/templates/accounts/user_update_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,40 +178,19 @@ <h3 class="panel-title">{% trans "Emails" %}</h3>
</div>
</div>
</div>
{% if not BROWSERID_ENABLED %}
<div class="col-lg-4 col-md-5 col-sm-12 col-xm-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
{% trans 'Change Password' %}
</h3>
</div>
<div class="panel-body">
<a href="{% url 'password_change' %}" class="btn btn-default btn-primary pull-right btn-block">{% trans "Change Password" %}</a>
</div>
<div class="col-lg-4 col-md-5 col-sm-12 col-xm-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
{% trans 'Change Password' %}
</h3>
</div>
</div>
{% endif %}
</div>
{% if CONVERSEJS_ENABLED %}
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
{% trans 'Change Password' %}
</h3>
</div>
<div class="panel-body">
<div class="form-group">
{% trans "This feature is available only for those who need to change the password for some reason as having an old user with the same username, forgot your password to commit, usage of other XMPP Client for connection. Usually, you won't need to change this password. Only change it if you are sure about what you are doing." %}
<div class="panel-body">
<a href="{% url 'password_change' %}" class="btn btn-default btn-primary pull-right btn-block">{% trans "Change Password" %}</a>
</div>
<a href="{% url 'change_password' %}" class="btn btn-default pull-right"><span class="icon-warning-sign"></span> {% trans "Change Password" %}</a>
</div>
</div>
</div>
</div>
{% endif %}
<div class="row">
<div class="submit">
<button type="submit" class="btn btn-primary btn-lg btn-block">{% trans "Update" %}</button>
Expand Down
7 changes: 0 additions & 7 deletions colab/accounts/tests/test_view_signup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ def create_user_django(self):
"usertest@colab.com.br", "123colab4")
return user

def test_user_not_authenticated(self):
with self.settings(BROWSERID_ENABLED=True):
response = self.client.get("/account/register")
self.assertEquals(302, response.status_code)
url = "http://testserver/account/login"
self.assertEquals(url, response.url)

def test_user_authenticated_and_unregistered(self):
self.client.login(username="usertestcolab", password="123colab4")
response = self.client.get("/account/register/")
Expand Down
58 changes: 23 additions & 35 deletions colab/accounts/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,44 @@
from django.conf import settings
from django.conf.urls import patterns, url

from .views import (UserProfileDetailView, UserProfileUpdateView, LoginView,
ManageUserSubscriptionsView, ChangeXMPPPasswordView)
from .views import (UserProfileDetailView, UserProfileUpdateView,
ManageUserSubscriptionsView)

from colab.accounts import views
from django.contrib.auth import views as auth_views


BROWSERID_ENABLED = getattr(settings, 'BROWSERID_ENABLED', False)
urlpatterns = patterns('',
url(r'^login/?$', 'django.contrib.auth.views.login', name='login'),

url(r'^logout/?$', 'django.contrib.auth.views.logout',
{'next_page':'home'}, name='logout'),

if not BROWSERID_ENABLED:
urlpatterns = patterns('',
url(r'^login/?$', 'django.contrib.auth.views.login', name='login'),
url(r'^password-reset-done/?$', 'colab.accounts.views.password_reset_done_custom',
name="password_reset_done"),
url(r'^password-reset-complete/$', 'colab.accounts.views.password_reset_complete_custom',
name="password_reset_complete"),

url(r'^logout/?$', 'django.contrib.auth.views.logout',
{'next_page':'home'}, name='logout'),
url(r'^password-reset-confirm/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$',
auth_views.password_reset_confirm,
{'template_name':'registration/password_reset_confirm_custom.html'},
name="password_reset_confirm"),

url(r'^password-reset-done/?$', 'colab.accounts.views.password_reset_done_custom',
name="password_reset_done"),
url(r'^password-reset-complete/$', 'colab.accounts.views.password_reset_complete_custom',
name="password_reset_complete"),
url(r'^password-reset/?$', auth_views.password_reset,
{'template_name':'registration/password_reset_form_custom.html'},
name="password_reset"),

url(r'^password-reset-confirm/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$',
auth_views.password_reset_confirm,
{'template_name':'registration/password_reset_confirm_custom.html'},
name="password_reset_confirm"),
url(r'^change-password/?$',auth_views.password_change,
{'template_name':'registration/password_change_form_custom.html'},
name='password_change'),

url(r'^password-reset/?$', auth_views.password_reset,
{'template_name':'registration/password_reset_form_custom.html'},
name="password_reset"),

url(r'^change-password/?$',auth_views.password_change,
{'template_name':'registration/password_change_form_custom.html'},
name='password_change'),

url(r'^change-password-done/?$',
'colab.accounts.views.password_changed', name='password_change_done'),
)
else:
urlpatterns = patterns('',
url(r'^login/?$', LoginView.as_view(), name='login'),
)
url(r'^change-password-done/?$',
'colab.accounts.views.password_changed', name='password_change_done'),
)

urlpatterns += patterns('',
url(r'^register/?$', 'colab.accounts.views.signup', name='signup'),

#FIXME Configure for XMPP
# url(r'^change-password/$',
# ChangeXMPPPasswordView.as_view(), name='change_password'),

url(r'^(?P<username>[\w@+.-]+)/?$',
UserProfileDetailView.as_view(), name='user_profile'),

Expand Down

0 comments on commit a2e34e5

Please sign in to comment.