mirror of https://github.com/zulip/zulip.git
[schema] Collect and display names and e-mail addresses.
(imported from commit aa6bceb05fcd5b456c03288cbfed65b14050fe88)
This commit is contained in:
parent
06711afa51
commit
bfdf2bef57
|
@ -45,8 +45,8 @@ var people_list = {{ people }};
|
|||
<div class="span3">
|
||||
<div class="zephyr_well well sidebar-nav">
|
||||
<ul class="nav nav-list nav-zephyr">
|
||||
<span class="realname">Your Name</span><br/>
|
||||
<span class="email">{{ user_profile.user.username }}@humbughq.com</span>
|
||||
<span class="realname">{{ user_profile.full_name }}</span><br/>
|
||||
<span class="email">{{ user_profile.email }}</span>
|
||||
<span class="logout">(<a href="/accounts/logout?next=/">not you?</a>)</span>
|
||||
<li><a href="subscriptions/">Manage subscriptions</a></li>
|
||||
<li><a href="#">View starred messages</a></li>
|
||||
|
|
|
@ -11,12 +11,22 @@ autofocus('#id_username');
|
|||
<form method="post" action="{% url register %}">
|
||||
{% csrf_token %}
|
||||
|
||||
{{ form.full_name.label_tag }}
|
||||
{{ form.full_name }}
|
||||
|
||||
{{ form.short_name.label_tag }}
|
||||
{{ form.short_name }}
|
||||
|
||||
{{ form.email.label_tag }}
|
||||
{{ form.email }}
|
||||
|
||||
{{ form.username.label_tag }}
|
||||
{{ form.username }}
|
||||
|
||||
{{ form.password.label_tag }}
|
||||
{{ form.password }}
|
||||
|
||||
<br />
|
||||
<input type="submit" value="Register" /><br />
|
||||
<input type="hidden" name="next" value="{{ next }}" />
|
||||
<input type="hidden" name="domain" value="humbughq.com" />
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
from django import forms
|
||||
|
||||
class RegistrationForm(forms.Form):
|
||||
full_name = forms.CharField(max_length=100)
|
||||
short_name = forms.CharField(max_length=100)
|
||||
email = forms.EmailField()
|
||||
username = forms.CharField(max_length=100)
|
||||
password = forms.CharField(widget=forms.PasswordInput, max_length=100)
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
</td>
|
||||
<td class="messagebox" onclick="select_zephyr({{id}})">
|
||||
<img class="profile_picture" src="http://www.gravatar.com/avatar/{{gravatar_hash}}?d=identicon"/>
|
||||
<span class="zephyr_label_clickable zephyr_sender"
|
||||
onclick="prepare_personal('{{sender}}')">{{sender}}</span>
|
||||
<span class="zephyr_label_clickable zephyr_sender" onclick="prepare_personal('{{sender}}')">
|
||||
<span class="zephyr_sender_name">{{sender_name}}</span> <span class="zephyr_sender_email">{{sender}}</span></span>
|
||||
<p class="zephyr_text">
|
||||
{{{html_content}}}
|
||||
</p></td>
|
||||
|
|
|
@ -17,7 +17,7 @@ def get_display_recipient(recipient):
|
|||
elif recipient.type == Recipient.HUDDLE:
|
||||
user_list = [UserProfile.objects.get(user=s.userprofile) for s in
|
||||
Subscription.objects.filter(recipient=recipient)]
|
||||
return [{'name': user.user.username} for user in user_list]
|
||||
return [{'name': user.short_name} for user in user_list]
|
||||
else:
|
||||
user = User.objects.get(id=recipient.type_id)
|
||||
return user.username
|
||||
|
@ -34,6 +34,8 @@ class Realm(models.Model):
|
|||
|
||||
class UserProfile(models.Model):
|
||||
user = models.OneToOneField(User)
|
||||
full_name = models.CharField(max_length=100)
|
||||
short_name = models.CharField(max_length=100)
|
||||
pointer = models.IntegerField()
|
||||
realm = models.ForeignKey(Realm)
|
||||
|
||||
|
@ -66,10 +68,11 @@ class UserProfile(models.Model):
|
|||
def __str__(self):
|
||||
return self.__repr__()
|
||||
|
||||
def create_user_profile(user, realm):
|
||||
def create_user_profile(user, realm, full_name, short_name):
|
||||
"""When creating a new user, make a profile for him or her."""
|
||||
if not UserProfile.objects.filter(user=user):
|
||||
profile = UserProfile(user=user, pointer=-1, realm_id=realm.id)
|
||||
profile = UserProfile(user=user, pointer=-1, realm_id=realm.id,
|
||||
full_name=full_name, short_name=short_name)
|
||||
profile.save()
|
||||
# Auto-sub to the ability to receive personals.
|
||||
recipient = Recipient(type_id=profile.id, type=Recipient.PERSONAL)
|
||||
|
@ -130,7 +133,8 @@ class Zephyr(models.Model):
|
|||
|
||||
def to_dict(self):
|
||||
return {'id' : self.id,
|
||||
'sender' : self.sender.user.username,
|
||||
'sender' : self.sender.user.email,
|
||||
'sender_name' : self.sender.full_name,
|
||||
'type' : self.recipient.type_name(),
|
||||
'display_recipient': get_display_recipient(self.recipient),
|
||||
'instance' : self.instance,
|
||||
|
|
|
@ -69,10 +69,14 @@ span.zephyr_instance {
|
|||
font-size: 120%;
|
||||
}
|
||||
|
||||
span.zephyr_sender {
|
||||
span.zephyr_sender_name {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
span.zephyr_sender_email {
|
||||
font-size: 80%;
|
||||
}
|
||||
|
||||
span.zephyr_label_clickable:hover {
|
||||
cursor: pointer;
|
||||
color: #08C;
|
||||
|
|
|
@ -43,15 +43,19 @@ def register(request):
|
|||
if form.is_valid():
|
||||
username = request.POST['username']
|
||||
password = request.POST['password']
|
||||
full_name = request.POST['full_name']
|
||||
short_name = request.POST['short_name']
|
||||
email = request.POST['email']
|
||||
domain = request.POST['domain']
|
||||
realm = Realm.objects.filter(domain=domain)
|
||||
if not realm:
|
||||
realm = Realm(domain=domain)
|
||||
realm.save()
|
||||
else:
|
||||
realm = Realm.objects.get(domain=domain)
|
||||
user = User.objects.create_user(username=username, password=password)
|
||||
user = User.objects.create_user(username=username, password=password, email=email)
|
||||
user.save()
|
||||
create_user_profile(user, realm)
|
||||
create_user_profile(user, realm, full_name, short_name)
|
||||
login(request, authenticate(username=username, password=password))
|
||||
return HttpResponseRedirect(reverse('zephyr.views.home'))
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue