Skip to content

Commit

Permalink
Merge branch 'master' into moderatornotifications
Browse files Browse the repository at this point in the history
  • Loading branch information
nlhkabu committed Jun 7, 2015
2 parents 5d7e0a5 + f503196 commit 5760ff7
Show file tree
Hide file tree
Showing 12 changed files with 145 additions and 48 deletions.
43 changes: 42 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ Please see ``TODO.rst`` for major planned features.
Documentation
_____________

Beginner documentation is available at http://django-mentor-connect.readthedocs.org/en/latest/
Documentation is available at http://django-mentor-connect.readthedocs.org/en/latest/

.. image:: https://readthedocs.org/projects/django-mentor-connect/badge/?version=latest
:target: https://readthedocs.org/projects/django-mentor-connect/?badge=latest
:alt: Documentation Status


Demo
Expand All @@ -35,6 +39,43 @@ Use the following authentication details to login:
|


Contributing
____________

After cloning the repo, install the requirements with:

pip install -r requirements/dev.txt

Create a local admin account with

python manage.py createsuperuser

And then check out the site with

python manage.py runserver


If you want to contribute changes to the code, you'll want to run the test suite.

Run the unit tests with

python manage.py test

And run the BDD tests with

python manage.py test bdd

To run an individual BDD feature, use, eg:

python manage.py test bdd --behave_include logout


Make sure all the BDD tests pass before submitting any PRs, and feel free to
add yourself to AUTHORS.rst if you want the glory!



Licence
_______

Expand Down
13 changes: 7 additions & 6 deletions bdd/features/steps/common.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import factory
from behave import *
from splinter.exceptions import ElementDoesNotExist
from behave import given, when, then
from django.core import management
from connect.accounts.factories import (InvitedPendingFactory, ModeratorFactory,
RequestedPendingFactory, UserFactory)
from connect.accounts.factories import (
InvitedPendingFactory, ModeratorFactory, RequestedPendingFactory, UserFactory
)

DEFAULT_WAIT = 5


# Setting up our users
Expand Down Expand Up @@ -208,7 +209,7 @@ def impl(context):
# Form Errors and Confirmation Messages
@then('I see "{message}"')
def impl(context, message):
if not context.browser.is_text_present(message, wait_time=3):
if not context.browser.is_text_present(message, wait_time=DEFAULT_WAIT):
raise AssertionError('could not find {message!r} in page body:\n{body}'.format(
message=message, body=context.browser.find_by_tag('body').text
))
Expand Down
13 changes: 7 additions & 6 deletions bdd/features/steps/invite_user.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from behave import *
from behave import given, then
from common import DEFAULT_WAIT


# Unique to Scenario: Moderator invites new user
Expand All @@ -13,9 +14,9 @@ def impl(context):

@then('I see that the user has been added to my list of invitations pending activation')
def impl(context):
assert context.browser.is_element_present_by_css('table.invitation-table', wait_time=5)
assert context.browser.is_text_present('First Last', wait_time=5)
assert context.browser.is_text_present('new.user@test.test', wait_time=5)
assert context.browser.is_text_present('Resend Invitation', wait_time=5)
assert context.browser.is_text_present('Revoke Invitation', wait_time=5)
assert context.browser.is_element_present_by_css('table.invitation-table', wait_time=DEFAULT_WAIT)
assert context.browser.is_text_present('First Last', wait_time=DEFAULT_WAIT)
assert context.browser.is_text_present('new.user@test.test', wait_time=DEFAULT_WAIT)
assert context.browser.is_text_present('Resend Invitation', wait_time=DEFAULT_WAIT)
assert context.browser.is_text_present('Revoke Invitation', wait_time=DEFAULT_WAIT)

9 changes: 5 additions & 4 deletions bdd/features/steps/moderate_abuse_reports.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from connect.accounts.factories import AbuseReportFactory, AbuseWarningFactory
from behave import *
from behave import given, then, when
from common import DEFAULT_WAIT


# Background
Expand Down Expand Up @@ -27,7 +28,7 @@ def impl(context):

@then('I see existing warnings')
def impl(context):
assert context.browser.is_text_present('One prior warning', wait_time=20)
assert context.browser.is_text_present('One prior warning', wait_time=DEFAULT_WAIT)

@then('I cannot see reports relating to myself')
def impl(context):
Expand All @@ -42,8 +43,8 @@ def impl(context):
@then('I see the prior warnings modal, with information inside it')
def impl(context):
assert context.browser.is_text_present('One prior warning for Standard User')
assert context.browser.is_text_present('This is a complaint', wait_time=20) # Default from our factory
assert context.browser.is_text_present('This is a formal warning', wait_time=20) # Default from our factory
assert context.browser.is_text_present('This is a complaint', wait_time=DEFAULT_WAIT) # Default from our factory
assert context.browser.is_text_present('This is a formal warning', wait_time=DEFAULT_WAIT) # Default from our factory
assert context.browser.is_text_present('by Another User')
assert context.browser.is_text_present('by Moderator User')

Expand Down
9 changes: 5 additions & 4 deletions bdd/features/steps/review_applications.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from behave import *
from behave import then
from common import DEFAULT_WAIT


# Unique to Scenario: View applications
@then('I see a list of pending applications')
def impl(context):
assert context.browser.is_element_present_by_css('.review-app-table')
assert context.browser.is_text_present('Pending', wait_time=10)
assert context.browser.is_text_present('Approval', wait_time=10)
assert context.browser.is_text_present('pending.approval@test.test', wait_time=10)
assert context.browser.is_text_present('Pending', wait_time=DEFAULT_WAIT)
assert context.browser.is_text_present('Approval', wait_time=DEFAULT_WAIT)
assert context.browser.is_text_present('pending.approval@test.test', wait_time=DEFAULT_WAIT)


# Unique to Scenario Outline: Moderator submits decision
Expand Down
5 changes: 3 additions & 2 deletions bdd/features/steps/revoke_invitation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from behave import *
from behave import then, when
from common import DEFAULT_WAIT


# Unique to Scenario: Moderator does not confirm revocation
Expand All @@ -14,4 +15,4 @@ def impl(context):
@then('the invited user has been removed from my pending invitations list')
def impl(context):
assert context.browser.is_text_not_present('invited.user@test.test',
wait_time=5)
wait_time=DEFAULT_WAIT)
11 changes: 6 additions & 5 deletions bdd/features/steps/view_dashboard.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import factory
from behave import *
from django.conf import settings
from behave import given, then, when
from connect.accounts.factories import UserFactory, UserSkillFactory
from connect.accounts.models import Role, Skill
from common import DEFAULT_WAIT


# Background
@given('the following users exist')
Expand Down Expand Up @@ -76,11 +77,11 @@ def impl(context):
@then('the member card expands')
def impl(context):
assert context.browser.is_element_present_by_css('table.skills',
wait_time=5)
wait_time=DEFAULT_WAIT)

@then('"View Full Profile" turns into "Collapse"')
def impl(context):
assert context.browser.is_text_present('Collapse', wait_time=5)
assert context.browser.is_text_present('Collapse', wait_time=DEFAULT_WAIT)


# Unique to Scenario: Report Abuse
Expand All @@ -91,7 +92,7 @@ def impl(context):
@then('I am taken to a new page to report that member')
def impl(context):
assert context.browser.is_text_present('Log an abuse report against',
wait_time=5)
wait_time=DEFAULT_WAIT)


# Unique to Scenario: Many users prompt pagination
Expand Down
16 changes: 9 additions & 7 deletions connect/accounts/templates/accounts/profile_settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,15 @@
<script src="{% static 'js/vendor/jquery.formset.js' %}"></script>
<script>
// Add additional fields to formsets
$('.skill-formset').formset({
prefix: '{{ skill_formset.prefix }}',
formCssClass: 'dynamic-skill-formset',
addText: '{% trans "add skill" %}',
deleteText: '{% trans "remove" %}',
deleteCssClass: 'delete-skill'
});
{% if has_skills %}
$('.skill-formset').formset({
prefix: '{{ skill_formset.prefix }}',
formCssClass: 'dynamic-skill-formset',
addText: '{% trans "add skill" %}',
deleteText: '{% trans "remove" %}',
deleteCssClass: 'delete-skill'
});
{% endif %}

$('.link-formset').formset({
prefix: '{{ link_formset.prefix }}',
Expand Down
33 changes: 32 additions & 1 deletion connect/accounts/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from connect.accounts import factories
from connect.accounts import views
from connect.accounts.models import UserLink, UserSkill
from connect.accounts.models import UserLink, UserSkill, Skill
from connect.config.factories import SiteConfigFactory
from connect.tests import BoostedTestCase as TestCase

Expand Down Expand Up @@ -259,6 +259,37 @@ def test_can_update_profile(self):
self.assertIn(expected_message, response.content.decode())


def test_can_update_profile_when_no_skills_exist(self):
self.client.login(username=self.standard_user.email, password='pass')

self.assertEqual(Skill.objects.count(), 0)

response = self.client.post(
reverse('accounts:profile-settings'),
data={
'full_name': 'New Full Name',
'bio': 'New bio',
'link-TOTAL_FORMS': 1,
'link-INITIAL_FORMS': 0,
'link-0-anchor': '',
'link-0-url': '',
},
)

self.assertEqual(response.status_code, 200)

user = User.objects.get(id=self.standard_user.id)
self.assertEqual(UserLink.objects.filter(user=user).count(), 0)
self.assertEqual(UserSkill.objects.filter(user=user).count(), 0)

self.assertEqual(user.full_name, 'New Full Name')
self.assertEqual(user.bio, 'New bio')

# Check that we see success message
expected_message = 'profile has been updated.'
self.assertIn(expected_message, response.content.decode())


class UpdateEmailTest(TestCase):
def setUp(self):
self.standard_user = factories.UserFactory()
Expand Down
13 changes: 9 additions & 4 deletions connect/accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,21 @@ def profile_settings(request):
skill_formset = SkillFormSet(request.POST, prefix='skill')
link_formset = LinkFormSet(request.POST, prefix='link')

if form.is_valid() and skill_formset.is_valid() \
and link_formset.is_valid():
forms = [form, link_formset]

if has_skills:
forms.append(skill_formset)

if all([f.is_valid() for f in forms]):
# Save user info
user.full_name = form.cleaned_data['full_name']
user.bio = form.cleaned_data['bio']
user.roles = form.cleaned_data['roles']

user.save()

save_skills(request, user, skill_formset)
if has_skills:
save_skills(request, user, skill_formset)

save_links(request, user, link_formset)

user_links = UserLink.objects.filter(user=user)
Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Connect
A *moderated* social platform that helps individuals connect based on location, skills and interests.
Connect is BSD licenced.

.. image::
https://codeship.com/projects/86e14520-1ec8-0132-5410-3e0b0834453b/status?branch=master
.. image:: https://travis-ci.org/nlhkabu/connect.svg?branch=master
:target: https://travis-ci.org/nlhkabu/connect

.. note::
Connect is in active development and not yet feature complete.
Expand Down
24 changes: 18 additions & 6 deletions docs/installation.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Installation
============

Connect is currently tested with ``Python 3.3`` and ``Django 1.7``.
Connect is currently tested with ``Python 3.4`` and ``Django 1.7 & 1.8``.


Dependencies
Expand Down Expand Up @@ -116,15 +116,27 @@ Now you can run your local sever:
#. Set up some additional data in your database. (See :doc:`configuration` for more information.)


Changing the Color
__________________
Edit scss files (style)
_______________________

Connect is built with Sass_.
Connect is built with Sass_ and Compass_.

If you need to install them, you will also need ``ruby`` but the installation process is beyond the scope of this project.

Please refer to the Saas and Compass documentation.


To compile locally your scss changes to the css file, use the command ``compass compile`` in the ``static/css`` folder of the app concerned by the changes.

You can change the default pink highlight color by editing the ``$highlight``
variable at the top of ``static/css/sass/_color.scss``

.. _Sass: http://sass-lang.com/
.. _Compass: http://compass-style.org/


.. rubric:: Example: Changing the highlighting color

You can change the default pink highlight color by editing the ``$highlight``
variable at the top of ``static/css/sass/_color.scss``


Running Tests
Expand Down

0 comments on commit 5760ff7

Please sign in to comment.