Revision 4d22fe8e crm/robocrm/admin.py

View differences:

crm/robocrm/admin.py
1
import string
1 2
from robocrm.models import Machine, Event, Project, RoboResource
3
from django.core.mail import send_mail
2 4
from django.forms import ModelForm, ValidationError
3 5
from django.contrib import admin
4 6
from django.contrib.auth.admin import UserAdmin
......
25 27
              'bench_status', 'shop_status')
26 28
          }),)
27 29

  
30
def subscribe_to_list(first_name, last_name, email, listname):
31
  if email == '':
32
    return
33

  
34
  name = string.strip(first_name + ' ' + last_name)
35
  if name == '':
36
    from_addr = email
37
  else:
38
    from_addr = '"' + name + '" <' + email + '>'
39

  
40
  to_addr = listname + '-subscribe@lists.andrew.cmu.edu'
41

  
42
  send_mail('', '', from_addr, [to_addr])
43

  
28 44
class RoboUserCreationForm(ModelForm):
29 45
  # This is modelled directly after django.contrib.auth.forms.UserCreationForm 
30 46

  
......
45 61
    user.set_password('geek6811')
46 62
    if commit:
47 63
      user.save()
64
    subscribe_to_list(user.first_name, user.last_name, user.email, 'roboclub-gb')
48 65
    return user
49 66

  
50 67
class RoboUserAdmin(UserAdmin):

Also available in: Unified diff