Skip to content

Commit

Permalink
Add related groups to remove from community form in members area.
Browse files Browse the repository at this point in the history
Added list columns for members admin view.
  • Loading branch information
yaniv14 committed Jul 17, 2016
1 parent 88e088e commit 8807d09
Show file tree
Hide file tree
Showing 21 changed files with 94 additions and 61 deletions.
Binary file modified src/acl/locale/he/LC_MESSAGES/django.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion src/acl/locale/he/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-17 11:37+0300\n"
"POT-Creation-Date: 2016-07-17 13:11+0300\n"
"PO-Revision-Date: 2016-06-07 11:27+0300\n"
"Last-Translator: \n"
"Language-Team: \n"
Expand Down
Binary file modified src/communities/locale/he/LC_MESSAGES/django.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion src/communities/locale/he/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Open Community\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-17 11:37+0300\n"
"POT-Creation-Date: 2016-07-17 13:11+0300\n"
"PO-Revision-Date: 2016-07-17 11:39+0300\n"
"Last-Translator: Yaniv Mirel <[email protected]>\n"
"Language-Team: \n"
Expand Down
Binary file modified src/communities/locale/he/LC_MESSAGES/djangojs.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion src/communities/locale/he/LC_MESSAGES/djangojs.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Open Community\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-17 11:37+0300\n"
"POT-Creation-Date: 2016-07-17 13:11+0300\n"
"PO-Revision-Date: 2014-02-11 12:50+0200\n"
"Last-Translator: Yaniv Mirel <[email protected]>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
14 changes: 10 additions & 4 deletions src/communities/templatetags/community_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from django.utils.translation import ugettext_lazy as _
from users.models import Membership


register = template.Library()


@register.filter
def display_upcoming_time(committee):
""" display only date if hour information if not set (remains at default '00:00)
Expand Down Expand Up @@ -40,13 +40,13 @@ def upcoming_status(committee):
ver = _("Version")
if committee.upcoming_meeting_published_at:
publish_time = timezone.localtime(
committee.upcoming_meeting_published_at)
committee.upcoming_meeting_published_at)
else:
publish_time = ''

meeting_version = u'{0} {1} - {2}'.format(ver,
committee.upcoming_meeting_version,
_date(publish_time, 'd F Y, H:i'))
committee.upcoming_meeting_version,
_date(publish_time, 'd F Y, H:i'))
if committee.upcoming_meeting_is_published:
if committee.straw_voting_enabled:
if committee.straw_vote_ended:
Expand All @@ -62,6 +62,12 @@ def upcoming_status(committee):

return rows


@register.filter
def remove_email(args):
return args.split('[')[0]


@register.filter()
def get_user_community_groups(user, arg):
return user.get_related_groups(arg)
Binary file modified src/issues/locale/he/LC_MESSAGES/django.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion src/issues/locale/he/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Open Community\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-17 11:37+0300\n"
"POT-Creation-Date: 2016-07-17 13:11+0300\n"
"PO-Revision-Date: 2015-05-14 13:18+0200\n"
"Last-Translator: Yaniv Mirel <[email protected]>\n"
"Language-Team: \n"
Expand Down
Binary file modified src/issues/locale/he/LC_MESSAGES/djangojs.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion src/issues/locale/he/LC_MESSAGES/djangojs.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Open Community\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-17 11:37+0300\n"
"POT-Creation-Date: 2016-07-17 13:11+0300\n"
"PO-Revision-Date: 2015-03-05 16:27+0200\n"
"Last-Translator: Yaniv Mirel <[email protected]>\n"
"Language-Team: \n"
Expand Down
Binary file modified src/meetings/locale/he/LC_MESSAGES/django.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion src/meetings/locale/he/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Open Community\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-17 11:37+0300\n"
"POT-Creation-Date: 2016-07-17 13:11+0300\n"
"PO-Revision-Date: 2015-05-14 13:18+0200\n"
"Last-Translator: Yaniv Mirel <[email protected]>\n"
"Language-Team: \n"
Expand Down
Binary file modified src/ocd/locale/he/LC_MESSAGES/django.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion src/ocd/locale/he/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Open Community\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-17 11:37+0300\n"
"POT-Creation-Date: 2016-07-17 13:11+0300\n"
"PO-Revision-Date: 2015-06-17 21:56+0200\n"
"Last-Translator: Yaniv Mirel <[email protected]>\n"
"Language-Team: \n"
Expand Down
16 changes: 14 additions & 2 deletions src/users/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,23 @@ class UserMembershipInline(admin.TabularInline):
class MembershipAdmin(admin.ModelAdmin):
list_display = (
'community',
'group_name',
'display_group_name',
'display_user_email',
'user',
'created_at',
)

list_filter = ('community', 'group_name',)
list_filter = ('community', 'group_name', 'user__email', 'user')
ordering = ['community', ]

def display_user_email(self, obj):
return obj.user.email

def display_group_name(self, obj):
return obj.group_name.title

display_user_email.short_description = _('Email')
display_group_name.short_description = _('Group')


class OCUserAdmin(UserAdmin):
Expand Down Expand Up @@ -107,6 +118,7 @@ def get_groups(self, obj):
for g in groups:
l.append(u'{0}: {1}'.format(g.group.title, g.committee.name))
return " | ".join(l)

get_groups.short_description = _('Committee & Groups')


Expand Down
Binary file modified src/users/locale/he/LC_MESSAGES/django.mo
Binary file not shown.
68 changes: 34 additions & 34 deletions src/users/locale/he/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Open Community\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-17 11:37+0300\n"
"POT-Creation-Date: 2016-07-17 13:11+0300\n"
"PO-Revision-Date: 2016-07-17 11:40+0300\n"
"Last-Translator: Yaniv Mirel <[email protected]>\n"
"Language-Team: \n"
Expand All @@ -31,7 +31,16 @@ msgstr ""
"סיסמאות אינם נשמרות כטקסט, אז אין אפשרות לראות את הסיסמא של המשתמש, אבל ניתן "
"לשנות סיסמא בעזרת <a href=\"password/\">הקישור הזה</a>."

#: .\admin.py:110
#: .\admin.py:82 .\models.py:288 .\templates\users\member_profile.html:24
msgid "Email"
msgstr "דואל"

#: .\admin.py:83 .\models.py:134 .\models.py:300 .\models.py:303
#: .\templates\users\member_update_form.html:9
msgid "Group"
msgstr "קבוצה"

#: .\admin.py:122
msgid "Committee & Groups"
msgstr "ועדות וקבוצות"

Expand Down Expand Up @@ -102,100 +111,91 @@ msgstr "משתמש"
msgid "users"
msgstr "משתמשים"

#: .\models.py:125 .\models.py:272
#: .\models.py:131 .\models.py:278
msgid "Community"
msgstr "קהילה"

#: .\models.py:127 .\models.py:287
#: .\models.py:133 .\models.py:293
msgid "User"
msgstr "משתמש"

#: .\models.py:128 .\models.py:294 .\models.py:297
#: .\templates\users\member_update_form.html:9
msgid "Group"
msgstr "קבוצה"

#: .\models.py:130
#: .\models.py:136
msgid "Old group"
msgstr "קבוצה ישנה"

#: .\models.py:132 .\models.py:275
#: .\models.py:138 .\models.py:281
msgid "Created at"
msgstr "נוצר בתאריך"

#: .\models.py:135
#: .\models.py:141
msgid "Invited by"
msgstr "הוזמן על ידי"

#: .\models.py:138
#: .\models.py:144
msgid "In position since"
msgstr "מכהן מתאריך"

#: .\models.py:143
#: .\models.py:149
msgid "Community Member"
msgstr "חבר קהילה"

#: .\models.py:144
#: .\models.py:150
msgid "Community Members"
msgstr "חברי קהילה"

#: .\models.py:262
#: .\models.py:268
msgid "Pending"
msgstr "ממתין למשלוח"

#: .\models.py:263
#: .\models.py:269
msgid "Sent"
msgstr "נשלח"

#: .\models.py:264
#: .\models.py:270
msgid "Failed"
msgstr "נכשל"

#: .\models.py:278
#: .\models.py:284
msgid "Created by"
msgstr "נוצר על ידי"

#: .\models.py:281
#: .\models.py:287
msgid "Name"
msgstr "שם"

#: .\models.py:282 .\templates\users\member_profile.html:24
msgid "Email"
msgstr "דואל"

#: .\models.py:283
#: .\models.py:289
msgid "Message"
msgstr "הודעה"

#: .\models.py:290
#: .\models.py:296
msgid "Groups"
msgstr "קבוצות"

#: .\models.py:300
#: .\models.py:306
msgid "Status"
msgstr "סטאטוס"

#: .\models.py:302
#: .\models.py:308
msgid "Times Sent"
msgstr "מספר הפעמים שההזמנה נשלחה"

#: .\models.py:303
#: .\models.py:309
msgid "Error count"
msgstr "מספר הפעימים שהמשלוח נכשל"

#: .\models.py:304
#: .\models.py:310
msgid "Sent at"
msgstr "נשלח לאחרונה ב"

#: .\models.py:309
#: .\models.py:315
msgid "Invitation"
msgstr "הזמנה"

#: .\models.py:310
#: .\models.py:316
msgid "Invitations"
msgstr "הזמנות"

#: .\models.py:312
#: .\models.py:318
#, python-format
msgid ""
"The system will allow you to take part in the decision making process of %s. "
Expand All @@ -207,7 +207,7 @@ msgstr ""
"אחרי אישור ההצטרפות ניתן לראות את הנושאים לדיון, את סדר היום לישיבה הקרובה, "
"ואת סיכום ההחלטות מהישיבות הקודמות, ובעתיד ניתן יהיה גם לדון ולהשפיע עליהם."

#: .\models.py:327
#: .\models.py:333
#, python-format
msgid "Invitation to %s"
msgstr "הזמנה לקהילה %s"
Expand Down
6 changes: 6 additions & 0 deletions src/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ def get_default_group(self, community):
except Membership.DoesNotExist:
return ""

def get_related_groups(self, community):
try:
return [x.group_name_id for x in self.memberships.filter(community=community)]
except Membership.DoesNotExist:
return None

def email_user(self, subject, message, from_email=None):
"""
Sends an email to this User.
Expand Down
33 changes: 21 additions & 12 deletions src/users/templates/users/member_update_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,29 @@

{% block content %}
{% csrf_token %}
{{form}}
{{ form }}
{% endblock %}

{% block scripts %}
<script>
$(function() {
$('#modal-form').on('shown.bs.modal', function (e) {
var members = [];
$('.members-list-abc input:checked').each(function () {
members.push($(this).val())
});
$('#id_members').val(members);
})
});
</script>
<script>
$(function () {
$('#modal-form').on('shown.bs.modal', function (e) {
var members = [];
var groups = [];
$('input[name="groups"]').prop('checked', false);
$('.members-list-abc input:checked').each(function () {
members.push($(this).val());
var user_groups_list = $(this).data('groups');
$.each(user_groups_list, function (i, el) {
if ($.inArray(el, groups) === -1) groups.push(parseInt(el));
});
});
$('#id_members').val(members);
$('input[name="groups"]').each(function () {
if ($.inArray(parseInt($(this).val()), groups) !== -1) $(this).prop('checked', true);
})
})
});
</script>

{% endblock %}
4 changes: 2 additions & 2 deletions src/users/templates/users/membership_groups.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "base.html" %}
{% load i18n %}
{% load i18n community_tags %}

{% block title %}
<title>
Expand Down Expand Up @@ -41,7 +41,7 @@ <h2>&nbsp;&nbsp;&nbsp;{{ member.user.display_name.0 }}</h2>

<div class="checkbox form-control members-list-abc">
<label>
<input type="checkbox" name="members" value="{{ member.user.id }}"> {{ member.user.display_name }}
<input type="checkbox" name="members" value="{{ member.user.id }}" data-groups="{{ member.user|get_user_community_groups:community }}"> {{ member.user.display_name }}
</label>
</div>
</div>
Expand Down

0 comments on commit 8807d09

Please sign in to comment.