Skip to content
This repository has been archived by the owner on Sep 26, 2018. It is now read-only.

Guardian permissions #45

Open
wants to merge 157 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 153 commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
f49b300
Updated for ForceFullyDeregister Tower
Apr 5, 2017
fd0a013
generalised code for deregister tower
Apr 6, 2017
7945ccf
Updated for ForceFullyDeregister Tower
Apr 5, 2017
3103133
generalised code for deregister tower
Apr 6, 2017
0322cc2
Revert "generalised code for deregister tower"
Apr 6, 2017
01f2662
updated review comments
Apr 6, 2017
8f410e3
updated No Data tower status check
Apr 10, 2017
87cc459
Add config file for browser extension
Sep 9, 2016
130200f
Add comment, remove trailing comma
Sep 9, 2016
1b1982e
Merge branch 'aricent_dev' of https://github.com/piyush-kr/CommunityC…
Apr 17, 2017
06c22aa
local working
Apr 17, 2017
dac1590
Merge remote-tracking branch 'origin/master' into aricent_dev
Apr 17, 2017
3b362c1
Revert "local working"
Apr 17, 2017
25da6ed
Merge branch 'master' of https://github.com/facebookincubator/Communi…
Apr 17, 2017
6f63fbf
Merge branch 'master' of https://github.com/piyush-kr/CommunityCellul…
Apr 17, 2017
d18b26e
Revert "Revert "local working""
Apr 17, 2017
63384a6
Revert "make sms_utilities py3 friendly [part 2 of more]"
Apr 17, 2017
90dbd42
Merge https://github.com/facebookincubator/CommunityCellularManager i…
May 2, 2017
7f10343
Added User Management with Subscriber Profiling
May 2, 2017
36ca3e7
env setting
shivkumarsah May 4, 2017
04cd8db
role permission implementation
shivkumarsah May 4, 2017
f59bb3d
migration
shivkumarsah May 4, 2017
5861ae4
role permission model changes
shivkumarsah May 4, 2017
9335fb3
Fix: User permission for user management.
sharma-sagar May 4, 2017
5e027cf
Adding reset templates
sharma-sagar May 4, 2017
a50fd02
Merging code for user management
sharma-sagar May 4, 2017
37a328d
Fix for permission selection
sharma-sagar May 4, 2017
9cb19d7
new permission assignment UI
shivkumarsah May 5, 2017
84aaf0e
new permission assignment UI
shivkumarsah May 5, 2017
32a0d16
new permission assignment UI
shivkumarsah May 5, 2017
f61a583
subcriber changes
May 5, 2017
91f498f
Merge branch 'aricent_dev' of https://github.com/piyush-kr/CommunityC…
May 5, 2017
97daade
network admin permission
shivkumarsah May 5, 2017
4fb34e1
network admin permission
shivkumarsah May 5, 2017
3d87957
Merge branch 'master' of https://github.com/piyush-kr/CommunityCellul…
shivkumarsah May 5, 2017
0d7c089
Merge branch 'aricent_dev'
shivkumarsah May 5, 2017
52b97bc
user add - validation added
shivkumarsah May 5, 2017
a413c78
validation
shivkumarsah May 5, 2017
9127640
validation
shivkumarsah May 5, 2017
6e22270
user delete - popup message
shivkumarsah May 5, 2017
c273709
Fix for User Block/Delete Management where same role was able to dele…
sharma-sagar May 7, 2017
bdfcc98
remove unused code
shivkumarsah May 8, 2017
f2a6f43
Merge branch 'aricent_dev' of https://github.com/piyush-kr/CommunityC…
shivkumarsah May 8, 2017
8664195
To avoid duplicacy of network names
sharma-sagar May 8, 2017
16bfa96
user delete/block popup
shivkumarsah May 8, 2017
307067b
Merge branch 'aricent_dev' of https://github.com/piyush-kr/CommunityC…
shivkumarsah May 8, 2017
eb2320b
Notification message, when blocked user tries to log in.
sharma-sagar May 8, 2017
f6178ae
Message when no user is blocked
sharma-sagar May 8, 2017
44d9287
Merge remote-tracking branch 'origin/aricent_dev' into aricent_dev
sharma-sagar May 8, 2017
c712520
Fix for Error message: when no user mataches query to delete
sharma-sagar May 8, 2017
6dc614b
Fixing: Handling of email already exists error.
sharma-sagar May 8, 2017
87557b0
permission in view
shivkumarsah May 8, 2017
3be1977
permission in view
shivkumarsah May 8, 2017
ed7af42
Fix: Block/Unblock Message
sharma-sagar May 8, 2017
fa12ce8
Merge remote-tracking branch 'origin/aricent_dev' into aricent_dev
sharma-sagar May 8, 2017
e37d7cd
Fix for block/unblock status for confirmation
sharma-sagar May 8, 2017
3bb5922
permission in view
shivkumarsah May 8, 2017
a53ee31
Merge branch 'aricent_dev' of https://github.com/piyush-kr/CommunityC…
shivkumarsah May 8, 2017
cf174de
Fix : Already existing User udated with error instead of warning,
sharma-sagar May 8, 2017
8e3bac6
Fix : Blank permission udated with error instead of warning,
sharma-sagar May 8, 2017
8f2b016
Fix : Permission selection
sharma-sagar May 8, 2017
eaae6e2
subscriber listing sorting
shivkumarsah May 8, 2017
30186f1
Merge branch 'aricent_dev' of https://github.com/piyush-kr/CommunityC…
shivkumarsah May 8, 2017
9e74aea
subscriber listing sorting
shivkumarsah May 8, 2017
d317bc4
permission
shivkumarsah May 8, 2017
a09b133
Fix : Fix for import
sharma-sagar May 8, 2017
75d3f6b
Fix : For incorrect layout of tower
sharma-sagar May 8, 2017
efbbc20
user add
shivkumarsah May 8, 2017
d809fda
Merge branch 'aricent_dev' of https://github.com/piyush-kr/CommunityC…
shivkumarsah May 8, 2017
f1cb947
user add - role and permission assignment
shivkumarsah May 8, 2017
f8b26e8
Adding Email Validation
sharma-sagar May 8, 2017
dcf9b5a
Merging Conflicts
sharma-sagar May 8, 2017
c352e56
Form Validation with Email and other fields, cannot submit form if va…
sharma-sagar May 8, 2017
277f46c
Adding Placeholder for email
sharma-sagar May 9, 2017
4cdda60
Fix: Handle netowrk list on user management and listing of networks d…
sharma-sagar May 9, 2017
34a0285
Fix: Permission fix for views
sharma-sagar May 9, 2017
0a49956
Fix: where layout Context was not available
sharma-sagar May 9, 2017
08083d5
permissions
shivkumarsah May 9, 2017
261c54c
user create - form validation
shivkumarsah May 9, 2017
eb02096
menu display change for single network display
shivkumarsah May 9, 2017
b8afd42
allow view network to all user
shivkumarsah May 9, 2017
a631d66
allow view network to all user
shivkumarsah May 9, 2017
72cc7b1
fix: for redirection on double click
sharma-sagar May 9, 2017
ef8f326
remove user view_network permission
shivkumarsah May 9, 2017
063a865
Merge branch 'aricent_dev' of https://github.com/piyush-kr/CommunityC…
shivkumarsah May 9, 2017
2fbde41
remove user view_network permission
shivkumarsah May 9, 2017
21e480f
remove user view_network permission
shivkumarsah May 9, 2017
0953733
Adding feature to send Password Reset Email (need to configure email …
sharma-sagar May 9, 2017
ed5052e
Vagarnt Uncommit other VMs
sharma-sagar May 9, 2017
d3cb222
updated with facebook-master
piyushabad88 May 10, 2017
f8b39f2
remove extra lines
shivkumarsah May 10, 2017
6571c63
gMerge branch 'aricent_dev' of https://github.com/piyush-kr/Community…
shivkumarsah May 10, 2017
7349604
Updated with email exception handling and submitting user
sharma-sagar May 10, 2017
1508f78
Fix for tower add
sharma-sagar May 10, 2017
94efcf1
user test cases
shivkumarsah May 10, 2017
738e513
formatted with pylint configuration
sharma-sagar May 10, 2017
a4fb20a
conflict resolve
sharma-sagar May 10, 2017
ff6b1cd
Replacing User with Subscriber Management
sharma-sagar May 10, 2017
c3b094d
user network view tab permission
shivkumarsah May 10, 2017
cd22e88
user network view tab permission
shivkumarsah May 10, 2017
01ff9a5
Merge branch 'aricent_dev' of https://github.com/piyush-kr/CommunityC…
shivkumarsah May 10, 2017
c54a973
user add - gui issue fixing
shivkumarsah May 10, 2017
8e1fb85
formatted as per pylint
sharma-sagar May 11, 2017
3cdb443
Fix: Subscriber Category Sorting w.r.t Name/IMSI
sharma-sagar May 11, 2017
608de07
Fixed typo
sharma-sagar May 11, 2017
e831901
Adding exception log on terminal (temporary)
sharma-sagar May 11, 2017
893dcec
Typo fix
sharma-sagar May 11, 2017
7f1dc72
Updated Views for Cloud/Network Admin and other user roles
sharma-sagar May 12, 2017
67dacab
Updated Views for Cloud/Network Admin and other user roles
sharma-sagar May 12, 2017
01d7c3c
Add config file for browser extension
Sep 9, 2016
37b92f5
Add comment, remove trailing comma
Sep 9, 2016
fb57c8d
local working
Apr 17, 2017
d52256b
Revert "local working"
Apr 17, 2017
2c82a99
Revert "Revert "local working""
Apr 17, 2017
0a15c7d
Revert "make sms_utilities py3 friendly [part 2 of more]"
Apr 17, 2017
f96aa0a
Added User Management with Subscriber Profiling
May 2, 2017
5c5e7dd
env setting
shivkumarsah May 4, 2017
98679a0
role permission implementation
shivkumarsah May 4, 2017
a21021b
migration
shivkumarsah May 4, 2017
2d5adb8
role permission model changes
shivkumarsah May 4, 2017
65012b8
Adding reset templates
sharma-sagar May 4, 2017
5587924
new permission assignment UI
shivkumarsah May 5, 2017
ec8960f
subcriber changes
May 5, 2017
f3c38ef
user delete - popup message
shivkumarsah May 5, 2017
2c956f1
remove unused code
shivkumarsah May 8, 2017
1a5b278
To avoid duplicacy of network names
sharma-sagar May 8, 2017
7f84278
Notification message, when blocked user tries to log in.
sharma-sagar May 8, 2017
cb767ee
Message when no user is blocked
sharma-sagar May 8, 2017
fcf2739
Fix for Error message: when no user mataches query to delete
sharma-sagar May 8, 2017
93d8b7d
subscriber listing sorting
shivkumarsah May 8, 2017
940aa8d
Fix : Fix for import
sharma-sagar May 8, 2017
64e1335
Fix: where layout Context was not available
sharma-sagar May 9, 2017
ad95ce1
remove user view_network permission
shivkumarsah May 9, 2017
74f7f29
user test cases
shivkumarsah May 10, 2017
99ab9d0
Replacing User with Subscriber Management
sharma-sagar May 10, 2017
4198de6
user network view tab permission
shivkumarsah May 10, 2017
d1bde52
user network view tab permission
shivkumarsah May 10, 2017
ed48888
Typo fix
sharma-sagar May 11, 2017
a6970be
rebase with master and resolve conflict
piyushabad88 May 15, 2017
3db81f1
removed unwanted comments
piyushabad88 May 15, 2017
a88f747
removed unnecessary files
piyushabad88 May 16, 2017
c1213b9
removed unnecessary files
piyushabad88 May 16, 2017
efaa47e
refactored with comments
piyushabad88 May 16, 2017
6f67807
Delete gen_xml_cdr_fixtures.sh
piyushabad88 May 16, 2017
c759272
code changes w.r.t comments.
sharma-sagar May 17, 2017
1e3759c
code changes w.r.t comments__Fixed TypeError due to typo
sharma-sagar May 18, 2017
ff353dd
Merge branch 'master' of https://github.com/facebookincubator/Communi…
piyushabad88 May 26, 2017
ac69b91
Added Guardian permissions
sharma-sagar Jun 6, 2017
ed947c6
Removed comments and add 403 for add user
sharma-sagar Jun 7, 2017
750dbdb
Merge remote-tracking branch 'remotes/upstream/master' into guardian_…
sharma-sagar Jun 27, 2017
e789c64
Merge branch 'master' of https://github.com/facebookincubator/Communi…
sharma-sagar Jun 30, 2017
213a282
Guardian Permission with User Management (sprint 1)
sharma-sagar Jun 30, 2017
b302fd8
Disable Network in Add
sharma-sagar Jun 30, 2017
cab4227
Incorporated changes for PR-45
sharma-sagar Jul 13, 2017
3ed0bf7
Guardian Redesign and Edit User
sharma-sagar Aug 3, 2017
771efad
Merge branch 'master' into guardian_features
sharma-sagar Aug 4, 2017
04ed325
Fixed typo for tower add
sharma-sagar Aug 10, 2017
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
42 changes: 35 additions & 7 deletions cloud/endagaweb/forms/dashboard_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@

import datetime

import pytz
from crispy_forms.bootstrap import StrictButton, FieldWithButtons
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Submit, Field
from django import forms
from django.contrib.auth.forms import PasswordChangeForm, PasswordResetForm
from django.contrib.auth.models import User
from django.core import urlresolvers
from django.db.models import Value
from django.db.models.functions import Coalesce
from django.core import urlresolvers
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Submit, Field
from crispy_forms.bootstrap import StrictButton, FieldWithButtons
from django.contrib.auth.forms import PasswordChangeForm
import pytz

from ccm.common.currency import CURRENCIES
from endagaweb import models
Expand Down Expand Up @@ -190,7 +191,7 @@ def __init__(self, *args, **kwargs):
self.helper.form_class = 'profile-form'
update_button = StrictButton('Update', css_class='btn-default',
type='submit')
self.helper.layout = Layout(FieldWithButtons('notify_numbers', update_button))
self.helper.layout = Layout(FieldWithButtons('notify_numbers', update_button))


class SubVacuumForm(forms.Form):
Expand Down Expand Up @@ -368,3 +369,30 @@ def __init__(self, *args, **kwargs):
self.helper.form_action = '/dashboard/staff/tower-monitoring'
self.helper.add_input(Submit('submit', 'Select'))
self.helper.layout = Layout('tower')


class UserSearchForm(forms.Form):
"""Crispy search form on /dashboard/subscribers."""
query = forms.CharField(required=False, label="Search Username")

def __init__(self, sender, *args, **kwargs):
self.helper = FormHelper()
self.helper.form_id = 'id-SearchForm'
self.helper.form_method = 'get'
if 'blocking' is sender:
self.helper.form_action = '/dashboard/user/management/blocking'
else:
self.helper.form_action = '/dashboard/user/management/delete'
# self.helper.form_class = 'form-vertical'
Copy link
Contributor

Choose a reason for hiding this comment

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

deaddcode

search_button = StrictButton('Find', css_class='btn-default',
type='submit')
self.helper.layout = Layout(FieldWithButtons('query', search_button))
super(UserSearchForm, self).__init__(*args, **kwargs)



class PasswordResetRequestForm(PasswordResetForm):
email = forms.CharField(label=("Email"), max_length=254)
class Meta:
model = User
fields = ("email")
52 changes: 43 additions & 9 deletions cloud/endagaweb/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,33 @@
'outside_call', 'outside_sms', 'local_call', 'local_sms',
)

PERMISSIONS = (
('user_management', 'User Management'),

('view_bts', 'View Tower'),
('add_bts', 'Add Tower'),
('edit_bts', 'Edit Tower'),
('delete_bts', 'Delete Tower'),

('view_subscriber', 'View Subscriber'),
('edit_subscriber', 'Edit Subscriber'),
('delete_subscriber', 'Delete Subscriber'),

('view_usage', 'View Usage'),
('download_usage', 'Download Usage Report'),

('view_network', 'View Network'), # default permission
('edit_network', 'Edit Network'),

('adjust_credit', 'Adjust Credit'),

('send_bulk_sms', 'Bulk SMS'),
('send_sms', 'Broadcast SMS'),

('view_graph', 'View Graph'),
('download_graph', 'Download Graphical Report'),
)


class UserProfile(models.Model):
"""UserProfiles extend the default Django User models.
Expand All @@ -71,7 +98,7 @@ class UserProfile(models.Model):
timezone_choices = [(v, v) for v in pytz.common_timezones]
timezone = models.CharField(max_length=50, default='UTC',
choices=timezone_choices)

role = models.CharField(max_length=20, default='Cloud Admin')
# A UI kludge indicate which network a user is currently viewing
# Important: This is not the only network a User is associated with
# because a user may have permissions on other Network instances.
Expand Down Expand Up @@ -103,7 +130,9 @@ def new_user_hook(sender, instance, created, **kwargs):
"""
if created and instance.username != settings.ANONYMOUS_USER_NAME:
profile = UserProfile.objects.create(user=instance)
network = Network.objects.create()
# Add explicit name to avoid duplicate names when
# running setup_test_db
network = Network.objects.create(name='Network_%s' % (instance.pk,))
network.auth_group.user_set.add(instance)
network.save()
# Make this the users currently selected network
Expand Down Expand Up @@ -296,6 +325,9 @@ class BTS(models.Model):
#none is unknown or invalid
channel = models.IntegerField(null=True, blank=True)

class Meta:
default_permissions = ()

def __unicode__(self):
return "BTS(%s, %s, last active: %s)" % (
self.uuid, self.inbound_url, self.last_active)
Expand Down Expand Up @@ -792,6 +824,9 @@ class UsageEvent(models.Model):
timespan = models.DecimalField(null=True, max_digits=7, decimal_places=1)
date_synced = models.DateTimeField(auto_now_add=True)

class Meta:
default_permissions = ()

def voice_sec(self):
"""Gets the number of seconds for this call.

Expand Down Expand Up @@ -980,9 +1015,8 @@ class Network(models.Model):
environment = models.TextField(default="default")

class Meta:
permissions = (
('view_network', 'View network'),
)
default_permissions = ()
permissions = PERMISSIONS

@property
def api_token(self):
Expand Down Expand Up @@ -1432,14 +1466,14 @@ def create_auth(sender, instance, created, **kwargs):
authenticate.
"""
if not instance.auth_group or not instance.auth_user:
instance.auth_group, created_group = Group.objects.get_or_create(name='network_%s'
% instance.pk)
instance.auth_group, created_group = Group.objects.get_or_create(name='%s_GROUP_%s' %
(instance.name, instance.pk))
if created_group:
assign_perm('view_network', instance.auth_group, instance)

post_save.disconnect(UserProfile.new_user_hook, sender=User)
instance.auth_user, created_user = User.objects.get_or_create(username='network_%s'
% instance.pk)
instance.auth_user, created_user = User.objects.get_or_create(username='%s_USER_%s' %
(instance.name, instance.pk))
if created_user:
Token.objects.create(user=instance.auth_user)
instance.auth_group.user_set.add(instance.auth_user)
Expand Down
Loading