def add(request, id): g = Group.objects.get(id=id) if request.method == 'POST': netids = [i.strip() for i in string.split(request.POST['netids'], ",")] for i in netids: if len(i) > 0: try: m = Member.objects.get(username=i) gm = GroupMember(member=m, group=g) gm.save() messages.add_message( request, messages.SUCCESS, 'Member added: %s' % m.full_name_and_netid()) except Member.DoesNotExist: messages.add_message(request, messages.ERROR, 'Bad netid: %s' % i) except IntegrityError: messages.add_message( request, messages.INFO, 'Duplicate member: %s' % m.full_name_and_netid()) return HttpResponseRedirect('/intranet/group/manage/' + id) members = Member.objects.filter(status='active') return render_to_response('intranet/group_manager/add.html', { "section": "intranet", "page": 'group', "group": g, "members": members }, context_instance=RequestContext(request))
def add(request,id): g = Group.objects.get(id=id) if request.method == 'POST': netids = [i.strip() for i in string.split(request.POST['netids'],",")] for i in netids: if len(i) > 0: try: m = Member.objects.get(username=i) gm = GroupMember(member=m,group=g) gm.save() messages.add_message(request, messages.SUCCESS, 'Member added: %s'%m.full_name_and_netid()) except Member.DoesNotExist: messages.add_message(request, messages.ERROR, 'Bad netid: %s'%i) except IntegrityError: messages.add_message(request, messages.INFO, 'Duplicate member: %s'%m.full_name_and_netid()) return HttpResponseRedirect('/intranet/group/manage/'+id) members = Member.objects.filter(status='active') return render_to_response('intranet/group_manager/add.html',{ "section":"intranet", "page":'group', "group":g, "members": members },context_instance=RequestContext(request))
os.system('cd liquid; python manage.py syncdb --noinput;') os.system('cd liquid; python manage.py migrate intranet;') os.system('cd liquid; python manage.py migrate intranet.chroma;') from intranet.models import Member, Group, GroupMember from datetime import datetime netid = raw_input('netid? ') uin = raw_input('uin? ') acct_pass = getpass.getpass("account password? ") # setup mailing lists from utils.django_mailman.models import List t_list = List(name="top4") m_list = List(name="Membership-l") j_list = List(name="Jobs-l") t_list.save() m_list.save() j_list.save() m = Member(username=netid, uin=uin) m.set_password(acct_pass) m.save() g = Group(name='Top4', type='O', date_formed=datetime.now(), mailing_list=t_list) g.save() GroupMember(member=m, group=g, is_chair=True, is_admin=True).save()
sys.path.append(os.path.abspath('app'),), import settings setup_environ(settings), from intranet.models import Member, Group, GroupMember from utils.django_mailman.models import List netid = raw_input('netid? ') uin = raw_input('uin? ') acct_pass = getpass.getpass("account password? ") # setup mailing lists t_list = List(name="top4") m_list = List(name="Membership-l") j_list = List(name="Jobs-l") t_list.save() m_list.save() j_list.save() m = Member(username=netid,uin=uin) m.set_password(acct_pass) m.save() g = Group(name='Top4',type='O',date_formed=datetime.now(), mailing_list=t_list) g.save() gm = GroupMember(member=m,group=g,is_chair=True,is_admin=True) gm.save()