Commit ad7b9ac7 by Oláh István Gergely

dashboard: move textbox to userlist

parent 94002b21
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<textarea name="list-new-list" class="form-control"></textarea>
<div class="form-actions"> <div class="form-actions">
<button type="submit" class="btn btn-success">{% trans "Save" %}</button> <button type="submit" class="btn btn-success">{% trans "Save" %}</button>
</div> </div>
...@@ -88,7 +89,6 @@ ...@@ -88,7 +89,6 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<textarea name="perm-new-list" class="form-control"></textarea>
<div class="form-actions"> <div class="form-actions">
<button type="submit" class="btn btn-success">{% trans "Save" %}</button> <button type="submit" class="btn btn-success">{% trans "Save" %}</button>
......
...@@ -595,8 +595,10 @@ class GroupDetailView(CheckedDetailView): ...@@ -595,8 +595,10 @@ class GroupDetailView(CheckedDetailView):
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
if request.POST.get('new_name'): if request.POST.get('new_name'):
return self.__set_name(request) return self.__set_name(request)
if request.POST.get('list-new-name'): if request.POST.get('list-new-name') is not None:
return self.__add_user(request) return self.__add_user(request)
elif request.POST.get('list-new-list') is not None:
return self.__add_list(request)
def __add_user(self, request): def __add_user(self, request):
name = request.POST['list-new-name'] name = request.POST['list-new-name']
...@@ -604,14 +606,19 @@ class GroupDetailView(CheckedDetailView): ...@@ -604,14 +606,19 @@ class GroupDetailView(CheckedDetailView):
def __add_username(self, request, name): def __add_username(self, request, name):
self.object = self.get_object() self.object = self.get_object()
if not name: if not name:
return return redirect(reverse_lazy("dashboard.views.group-detail",
kwargs={'pk': self.object.pk}))
try: try:
entity = User.objects.get(username=name) entity = User.objects.get(username=name)
self.object.user_set.add(entity)
except User.DoesNotExist: except User.DoesNotExist:
warning(request, _('User "%s" not found.') % name) warning(request, _('User "%s" not found.') % name)
return return redirect(reverse_lazy("dashboard.views.group-detail",
self.object.user_set.add(entity) kwargs={'pk': self.object.pk}))
def __add_list(self, request, name):
return redirect(reverse_lazy("dashboard.views.group-detail", return redirect(reverse_lazy("dashboard.views.group-detail",
kwargs={'pk': self.object.pk})) kwargs={'pk': self.object.pk}))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment