Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:tu-software-studio/tinyhands int…
Browse files Browse the repository at this point in the history
…o develop
  • Loading branch information
Tom Nurkkala committed Dec 21, 2015
2 parents f0b00d6 + 5e74909 commit 639f9c7
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 10 deletions.
6 changes: 6 additions & 0 deletions accounts/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ class Meta:
model = Account
exclude = ['password', 'activation_key', 'groups','user_permissions', 'is_staff', 'is_superuser']

def create(self, validated_data):
account = Account.objects.create(**validated_data)
account.send_activation_email()
return account


class DefaultPermissionsSetSerializer(serializers.ModelSerializer):
is_used_by_accounts = serializers.BooleanField(read_only=True);

Expand Down
2 changes: 2 additions & 0 deletions accounts/static/accounts/js/services/accounts.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ angular.module('AccountsMod')
method: 'GET'
},
all: {
url: '/api/account/all/',
isArray : true,
method: 'GET'
},
get: {
Expand Down
19 changes: 10 additions & 9 deletions accounts/templates/accounts/account_activate.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% extends "accounts/account_base.html" %}
{% block html %}{% endblock %}
{% load bootstrap %}

{% block title %}Activate Account{% endblock %}
Expand All @@ -8,16 +9,16 @@
{% block content %}
<div class="container">
{% if invalid_key %}
<h1>This account has already been activated or your activation key is invalid. Please contact your administrator.</h1>
<h1>This account has already been activated or your activation key is invalid. Please contact your administrator.</h1>
{% else %}
<h1>Activate Your Account</h1>
<p>Your account is almost ready &mdash; just enter a password.</p>
<div class="row">
<form method="POST" class="col-sm-6">{% csrf_token %}
{{ form|bootstrap }}
<input type="submit" class="btn btn-primary btn-lg" value="Create" />
</form>
</div>
<h1>Activate Your Account</h1>
<p>Your account is almost ready &mdash; just enter a password.</p>
<div class="row">
<form method="POST" class="col-sm-6">{% csrf_token %}
{{ form|bootstrap }}
<input type="submit" class="btn btn-primary btn-lg" value="Create" />
</form>
</div>
{% endif %}
</div>
{% endblock %}
2 changes: 1 addition & 1 deletion accounts/templates/accounts/account_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h1>All Accounts</h1>
</thead>

<tbody>
<tr ng-repeat="account in accountsCtrl.accounts.results" id="{{account.id}}">
<tr ng-repeat="account in accountsCtrl.accounts" id="{{account.id}}">
<td>{{account.email}}</td>
<td>{{account.first_name}}</td>
<td>{{account.last_name}}</td>
Expand Down
6 changes: 6 additions & 0 deletions accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from braces.views import LoginRequiredMixin
from extra_views import ModelFormSetView
from rest_framework import status
from rest_framework.decorators import list_route
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
Expand Down Expand Up @@ -152,6 +153,11 @@ class AccountViewSet(ModelViewSet):
permission_classes = [IsAuthenticated, HasPermission]
permissions_required = ['permission_accounts_manage']

@list_route()
def list_all(self, request):
accounts = Account.objects.all()
serializer = self.get_serializer(accounts, many=True)
return Response(serializer.data)

class DefaultPermissionsSetViewSet(ModelViewSet):
queryset = DefaultPermissionsSet.objects.all()
Expand Down
1 change: 1 addition & 0 deletions rest_api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
url(r'^me/$', CurrentUserView.as_view(), name="CurrentUser"),

url(r'^account/$', AccountViewSet.as_view({'get': 'list', 'post':'create'}), name="AccountList"),
url(r'^account/all/$', AccountViewSet.as_view({'get': 'list_all'}), name="AccountListAll"),
url(r'^account/(?P<pk>\d+)/$', AccountViewSet.as_view({'get':'retrieve', 'put':'update', 'delete':'destroy'}), name='Account'),
url(r'^account/resend-activation-email/(?P<pk>\d+)/$', ResendActivationEmailView.as_view(), name='ResendActivationEmail'),

Expand Down

0 comments on commit 639f9c7

Please sign in to comment.