File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -236,9 +236,13 @@ def profile(request):
236236 r .email = e
237237 r .save ()
238238
239+ primary_email = request .POST .get ("primary_email" , None )
239240 active_emails = request .POST .getlist ("active_emails" , [])
240241 for email in emails :
241242 email .active = email .pk in active_emails
243+ email .primary = email .address == primary_email
244+ if email .primary and not email .active :
245+ email .active = True
242246 email .save ()
243247
244248 # Make sure the alias table contains any new and/or old names.
Original file line number Diff line number Diff line change @@ -710,3 +710,8 @@ blockquote {
710710 margin : inherit;
711711 border-left : inherit;
712712}
713+
714+ # emails {
715+ padding-top : 4px ;
716+ padding-right : 4px ;
717+ }
Original file line number Diff line number Diff line change @@ -34,14 +34,16 @@ <h1>Profile for {{ user.username }}</h1>
3434 < div class ="col-sm-10 ">
3535 < div class ="row ">
3636 < div class ="col-sm-5 " id ="emails ">
37- {% for email in emails %}
38- < div class ="checkbox ">
39- < label >
40- < input type ="checkbox " name ="active_emails " value ="{{ email.pk }} " {% if email.active %}checked{% endif %} >
41- {{ email }}
42- </ label >
43- </ div >
44- {% endfor %}
37+ < table class ="table table-condensed ">
38+ < tr > < th > Primary</ th > < th > Active</ th > < th > Address</ th > </ tr >
39+ {% for email in emails %}
40+ < tr >
41+ < td > < input type ="radio " name ="primary_email " value ="{{ email.pk }} " {% if email.primary %}checked{% endif %} > </ td >
42+ < td > < input type ="checkbox " name ="active_emails " value ="{{ email.pk }} " {% if email.active %}checked{% endif %} > </ td >
43+ < td > {{ email }}</ td >
44+ </ tr >
45+ {% endfor %}
46+ </ table >
4547 </ div >
4648 < div class ="col-sm-7 ">
4749 < div class ="help-block "> Note: Email addresses cannot be deleted, only deactivated.</ div >
@@ -81,11 +83,11 @@ <h1>Profile for {{ user.username }}</h1>
8183 $ ( document ) . ready ( function ( ) {
8284 $ ( "input[name=active_emails]" ) . on ( "change keypress click" , function ( ) {
8385 if ( this . checked ) {
84- $ ( this ) . parent ( ) . addClass ( "text-success" ) ; ;
85- $ ( this ) . parent ( ) . removeClass ( "text-danger line-through" ) ;
86+ $ ( this ) . parent ( ) . parent ( ) . addClass ( "text-success" ) ; ;
87+ $ ( this ) . parent ( ) . parent ( ) . removeClass ( "text-danger line-through" ) ;
8688 } else {
87- $ ( this ) . parent ( ) . addClass ( "text-danger line-through" ) ;
88- $ ( this ) . parent ( ) . removeClass ( "text-success" ) ;
89+ $ ( this ) . parent ( ) . parent ( ) . addClass ( "text-danger line-through" ) ;
90+ $ ( this ) . parent ( ) . parent ( ) . removeClass ( "text-success" ) ;
8991 }
9092 } ) . trigger ( "change" ) ;
9193
You can’t perform that action at this time.
0 commit comments