Skip to content

Commit

Permalink
use a managed_user property to differentiate admin, non-admin and system
Browse files Browse the repository at this point in the history
  • Loading branch information
schakrava committed Jul 6, 2015
1 parent d01bc36 commit a768c5b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/rockstor/storageadmin/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,13 @@ def groupname(self, *args, **kwargs):
return grp.getgrgid(self.gid).gr_name
return None

@property
def managed_user(self, *args, **kwargs):
return getattr(self, 'editable', True)

@managed_user.setter
def managed_user(self, val, *args, **kwargs):
self.editable = val

class Meta:
app_label = 'storageadmin'
1 change: 1 addition & 0 deletions src/rockstor/storageadmin/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class Meta:

class SUserSerializer(serializers.ModelSerializer):
groupname = serializers.CharField()
managed_user = serializers.BooleanField(default=True)

class Meta:
model = User
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@
<td><%= user.get('gid') %></td>
<td><%= user.get('shell') %></td>
<td>
<% if (user.get('managed_user')) { %>
<a href="#" class="edit-user" data-username="<%= user.get('username') %>" rel="tooltip" title="Edit user"><i class="glyphicon glyphicon-pencil"></i></a>
<a href="#" class="delete-user" data-username="<%= user.get('username') %>" rel="tooltip" title="Delete user"><i class="glyphicon glyphicon-trash"></i></a>
</td>
<% } %>
</tr>
<% } %>
<% }); %>
Expand Down
6 changes: 4 additions & 2 deletions src/rockstor/storageadmin/views/ug_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ def combined_users():
uo.save()
users.append(uo)
except User.DoesNotExist:
users.append(User(username=u, uid=sys_users[u][0],
gid=sys_users[u][1], admin=False))
temp_uo = User(username=u, uid=sys_users[u][0],
gid=sys_users[u][1], admin=False)
temp_uo.managed_user = False
users.append(temp_uo)
for u in User.objects.all():
if (u.username not in uname_list):
users.append(u)
Expand Down

0 comments on commit a768c5b

Please sign in to comment.