mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-31 14:42:10 +00:00
Rewrite get registerred contacts
This commit is contained in:
@@ -4,6 +4,8 @@ from django.db import models
|
||||
from django.forms import ModelForm
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from seaserv import ccnet_threaded_rpc
|
||||
|
||||
from seahub.base.fields import LowerCaseCharField
|
||||
from settings import CONTACT_EMAIL_LENGTH
|
||||
|
||||
@@ -25,11 +27,16 @@ class ContactManager(models.Manager):
|
||||
|
||||
def get_registered_contacts_by_user(self, user_email):
|
||||
"""Get a user's registered contacts.
|
||||
"""
|
||||
from seahub.views import is_registered_user
|
||||
|
||||
return [ c for c in super(ContactManager, self).filter(
|
||||
user_email=user_email) if is_registered_user(c.contact_email) ]
|
||||
Returns:
|
||||
A list contains contact emails.
|
||||
"""
|
||||
contacts = [ c.contact_email for c in super(
|
||||
ContactManager, self).filter(user_email=user_email) ]
|
||||
emailusers = ccnet_threaded_rpc.filter_emailusers_by_emails(
|
||||
','.join(contacts))
|
||||
|
||||
return [ e.email for e in emailusers ]
|
||||
|
||||
class Contact(models.Model):
|
||||
"""Record user's contacts."""
|
||||
|
@@ -1,8 +1,8 @@
|
||||
{% load seahub_tags avatar_tags i18n %}
|
||||
//repo-share-form share-list autocomplete
|
||||
var share_list = [], contact_email, group_name, group_name_py;
|
||||
{% for contact in contacts %}
|
||||
contact_email = '{{ contact.contact_email }}';
|
||||
{% for contact_email in contacts %}
|
||||
contact_email = '{{ contact_email }}';
|
||||
share_list.push({value:contact_email, label:contact_email});
|
||||
{% endfor %}
|
||||
|
||||
|
@@ -31,11 +31,11 @@
|
||||
</div>
|
||||
<div id="share-contact-options" class="hide">
|
||||
<ul class="option-list">
|
||||
{% for contact in contacts %}
|
||||
{% for contact_email in contacts %}
|
||||
<li>
|
||||
<label class="checkbox-label">
|
||||
<span class="checkbox"><input type="checkbox" name="contact" value="{{ contact.contact_email }}" class="checkbox-orig" /></span>
|
||||
{% avatar contact.contact_email 20 %} <span class="checkbox-option">{{ contact.contact_email }}</span>
|
||||
<span class="checkbox"><input type="checkbox" name="contact" value="{{ contact_email }}" class="checkbox-orig" /></span>
|
||||
{% avatar contact_email 20 %} <span class="checkbox-option">{{ contact_email }}</span>
|
||||
</label>
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
Reference in New Issue
Block a user