Varun Sharma has proposed merging lp:~sharmavarun/postorius/postorius_gsoc2013 
into lp:postorius.

Requested reviews:
  Mailman Coders (mailman-coders)

For more details, see:
https://code.launchpad.net/~sharmavarun/postorius/postorius_gsoc2013/+merge/164011

Added delete user functionaly, created user_delete method to 
postorius/views/user.py and added template user_confirm_delete.html to 
templates. Right now users can be deleted by superuser only but as discussed on 
irc, self deletion of user may be added in future.
-- 
https://code.launchpad.net/~sharmavarun/postorius/postorius_gsoc2013/+merge/164011
Your team Mailman Coders is requested to review the proposed merge of 
lp:~sharmavarun/postorius/postorius_gsoc2013 into lp:postorius.
=== modified file 'src/postorius/forms.py'
--- src/postorius/forms.py	2013-03-21 18:43:28 +0000
+++ src/postorius/forms.py	2013-05-15 17:52:27 +0000
@@ -614,7 +614,11 @@
         required=False,
         choices=(
             ("", _("Please choose")),
-            ("delivery_mode", "some mode...")),
+            (1, "Regular"),
+            (2, "PlainText Digests"),
+            (3, "Mime Digests"),
+            (4, "Summary Digests"),
+                ),
         label=_('Delivery mode'))
     delivery_status = forms.ChoiceField(
         widget=forms.Select(),
@@ -623,7 +627,9 @@
         required=False,
         choices=(
             ("", _("Please choose")),
-            ("delivery_status", "some status...")),
+            (1, "Enabled"),
+            (2, "Disabled"),
+                ),
         label=_('Delivery status'))
 
     class Meta:

=== modified file 'src/postorius/templates/postorius/user_mailmansettings.html' (properties changed: -x to +x)
--- src/postorius/templates/postorius/user_mailmansettings.html	2013-04-08 04:07:50 +0000
+++ src/postorius/templates/postorius/user_mailmansettings.html	2013-05-15 17:52:27 +0000
@@ -15,9 +15,9 @@
         <h1>{% trans "Subscription Settings" %} <span>- {{ user }}</span></h1>
     </div>
 
-    <p><strong>Mailman display name:</strong> {{ mm_user.display_name}}</p>
-    <p><strong>Django email:</strong> {{ user.email }}</p>
-    <p><strong>Mailman primary email:</strong> {{ mm_user.email }}</p>
+    <p><strong>{% trans "Mailman display name" %} :</strong> {{ mm_user.display_name}}</p>
+    <p><strong>{% trans "Django email" %} :</strong> {{ user.email }}</p>
+    <p><strong>{% trans "Mailman primary email" %} :</strong> {{ mm_user.email }}</p>
     <h2>Valid email addresses for this account:</h2>
     <ul>
 <!-- ADDRESSES/EMAIL@/MEMBERSHIPS -->
@@ -29,27 +29,13 @@
     <h2 style="color: red">WARNING: This page is currently a mockup and
 anything below this line may not work</h2>
 
-    <h2>Preferences:</h2>
-    <p>preferences: {{ mm_user.preferences }}
-    <p>user: {{ mm_user }}
-    <p>tko
-    <p>memberships: {{ membership_lists }}
-    {% for pref in mm_user.preferences %}
-        <li>{{ pref }}</li>
-    {% endfor %}
     
     <h2>List memberships:</h2>
-    {% for list in mm_user.lists %}
-       <li>{{ list.name }}</li>
+    <ul>
+    {% for mailing_list in mm_user.subscriptions %}
+        <li>{{ mailing_list.list_id }} [<a href="/postorius/lists/{{ mailing_list.list_id }}/">listinfo</a>] 
+            [<a href="/postorius/lists/{{ mailing_list.list_id }}/settings/">settings</a>]</li>
     {% endfor %}
-    <p><em class="errorlist">Sample output: not real</em></p>
-    <ul>
-        <li>[email protected] [<a href="#">listinfo</a>] 
-            [<a href="#">settings</a>]</li>
-        <li>[email protected] [<a href="#">listinfo</a>] 
-            [<a href="#">settings</a>]</li>
-        <li>[email protected] [<a href="#">listinfo</a>] 
-            [<a href="#">settings</a>]</li>
     </ul>
 <!--
     <script type="text/javascript"
@@ -66,21 +52,23 @@
             });
         });
     </script> -->
+    <form action="{{submit_url}}" method="post"> {% csrf_token %}
     <h2>Prefs form</h2>
-    {{ settingsform.asp }}
+    <table class="table table-bordered table-striped mm_userData">
+    {{ settingsform }}
+    </table>
 
     <h2>List Preferences Overview</h2>
     <p><em class="errorlist">Sample output: not real</em></p>
     <input id="btnHide" type="button" value="{% trans "Hide Descriptions" %}"/>
-    <form action="#"> {% csrf_token %}
     <table class="table table-bordered table-striped">
         <tr>
             <th>{% trans "Setting" %}</th>
             <th>{% trans "Description" %}</th>
-            <th>{% trans "Set all" %}</th>
-            <th class="rotate">[email protected]</th>
-            <th class="rotate">[email protected]</th>
-            <th class="rotate">[email protected]</th>
+<!--            <th>{% trans "Set all" %}</th>-->
+        {% for subscription in mm_user.subscriptions %}
+            <th>{{ subscription.list_id }}</th>
+        {% endfor %}
         </tr>
         <tr>
             <th>{% trans "Mail delivery" %} ({{ preference }})</th>
@@ -91,25 +79,31 @@
         while (e.g. you're going on vacation).  If you disable mail
         delivery, don't forget to re-enable it when you come back; it
         will not be automatically re-enabled." </td>
-            <td><input type="checkbox" /></td>
-            <td><input type="checkbox" /></td>
-            <td><input type="checkbox" /></td>
-            <td><input type="checkbox" /></td>
+            {% for subscription in mm_user.subscriptions %}
+                <td><input type="checkbox" /></td>
+            {% endfor %}
         </tr>
+
     {% for preference in mm_user.preferences %}
     {% endfor %}
         <tr>
             <th colspan="6">{% trans "Per-Email subscriptions" %}</th>
         </tr>
         <tr>
-            <th colspan="2">[email protected]</th>
-            <td><input type="checkbox" /></td>
-            <td><input type="checkbox" /></td>
-            <td><input type="checkbox" /></td>
-            <td><input type="checkbox" /></td>
+        {% for address in mm_user.addresses %}
+            <th colspan="2">{{ address }}</th>
+            {% for subscription in mm_user.subscriptions %}
+            <td><input type="checkbox" /></td>
+            {% endfor %}
+        {% endfor %}
+<!--            <th colspan="2">[email protected]</th>
+            <td><input type="checkbox" /></td>-->
         <tr>
         </tr>
     </table>
+
+ <button class="btn btn-success" type="submit">{% trans "Save" %} {{ domain }}</button><a class="btn" style="margin-left:3px;" href="{% url 'domain_index' %}">{% trans "Cancel" %}</a>
+
     </form>
     {% endif %}
 {% endblock main %}

=== modified file 'src/postorius/templates/postorius/users/index.html'
--- src/postorius/templates/postorius/users/index.html	2013-03-29 22:04:06 +0000
+++ src/postorius/templates/postorius/users/index.html	2013-05-15 17:52:27 +0000
@@ -16,6 +16,7 @@
     		<tr>
     			<th>{% trans 'Email' %}</th>
     			<th>{% trans 'Display name' %}</th>
+                <th></th> <!-- header for delete user button -->
     			<!-- th>{% trans 'Web User' %}</th -->
     			<!--th>{% trans 'Mailman User' %}</th -->
     		</tr>
@@ -29,6 +30,10 @@
     			<td>
                     {{ mm_user.display_name }}
                 </td>
+                <td>
+                <a href="{{mm_user.user_id}}/delete" class="btn btn-mini btn-danger">Delete</a>
+                </td>
+
     			<!--td><i class="icon-ok"></i></td -->
     			<!--td><i class="icon-remove"></i></td -->
     		</tr>

=== added file 'src/postorius/templates/postorius/users/user_confirm_delete.html'
--- src/postorius/templates/postorius/users/user_confirm_delete.html	1970-01-01 00:00:00 +0000
+++ src/postorius/templates/postorius/users/user_confirm_delete.html	2013-05-15 17:52:27 +0000
@@ -0,0 +1,15 @@
+{% extends "postorius/base.html" %}
+{% load url from future %}
+{% load i18n %}
+{% load nav_helpers %}
+
+{% block main %}
+
+    <h1>{% trans 'Confirm Deletion' %}</h1>
+
+    <p>{% trans "Are you sure you want to permanently delete this user ?" %}</p>
+    <form action="{{submit_url}}" method="post"> {% csrf_token %}
+        <button class="btn btn-danger" type="submit">{% trans "Delete" %} {{ domain }}</button>
+        <a class="btn" href="{% url 'user_index' %}">{% trans "Cancel" %}</a>
+    </form>
+{% endblock main %}

=== modified file 'src/postorius/urls.py'
--- src/postorius/urls.py	2013-03-29 22:04:06 +0000
+++ src/postorius/urls.py	2013-05-15 17:52:27 +0000
@@ -83,6 +83,7 @@
    
     # /users/
     url(r'^users/(?P<page>\d+)/$', 'user_index', name='user_index_paged'),
+    url(r'^users/(?P<user_id>\d+)/delete$', 'user_delete', name='user_delete'),
     url(r'^users/$', 'user_index', name='user_index'),
     url(r'^users/new/$', 'user_new', name='user_new'),
     url(r'^users/(?P<user_id>[^/]+)/$',

=== modified file 'src/postorius/views/user.py'
--- src/postorius/views/user.py	2013-04-08 17:59:47 +0000
+++ src/postorius/views/user.py	2013-05-15 17:52:27 +0000
@@ -211,6 +211,33 @@
 
 
 @user_passes_test(lambda u: u.is_superuser)
+def user_delete(request,template='postorius/users/user_confirm_delete.html',**kwargs):
+    """Deletes a user upon after asking for confirmation.
+    """
+    if request.method == 'POST':
+        try:
+            user_id = kwargs["user_id"]
+            user = MailmanUser.objects.get(address=user_id) 
+            display_name = user.display_name
+            user.delete()
+            messages.success(request,
+                             _('The user %s has been deleted.' % display_name))
+            return redirect("user_index")
+        except HTTPError as e:
+            messages.error(request, _('The user could not be deleted:'
+                                      ' %s' % e.msg))
+            return redirect("user_index")
+
+    user_id = kwargs["user_id"]
+    submit_url = reverse('user_delete',
+                         kwargs={'user_id': user_id})
+    return render_to_response(template,
+                              {'user': request.user, 'submit_url': submit_url},
+                              context_instance=RequestContext(request))
+
+
+
+@user_passes_test(lambda u: u.is_superuser)
 def user_new(request):
     message = None
     if request.method == 'POST':

_______________________________________________
Mailman-coders mailing list
[email protected]
http://mail.python.org/mailman/listinfo/mailman-coders

Reply via email to