def sendmail(request): if request.method == 'POST': form = NewMailForm(request.POST) if form.is_valid(): title = form.cleaned_data['title'] content = form.cleaned_data['content'] readers = form.cleaned_data['reader'] targets = Student.objects(url_number__in=readers) creators = S_S_Card.objects(user=request.user, target__in=targets) print creators url_number = len(Sitemail.objects) + 1 mail = Sitemail(title=title, content=content, creator=creators, creat_time=datetime.datetime.now(), is_readed=False, url_number=url_number).save() return HttpResponseRedirect('/sitemail/outbox/') else: form = NewMailForm() return render_to_response('sitemail/sendmail.html', { 'STATIC_URL': STATIC_URL, 'current_user': request.user, 'form': form }, context_instance=RequestContext(request))
def sendmail(request): if request.method == "POST": form = NewMailForm(request.POST) if form.is_valid(): title = form.cleaned_data["title"] content = form.cleaned_data["content"] readers = form.cleaned_data["reader"] targets = Student.objects(url_number__in=readers) creators = S_S_Card.objects(user=request.user, target__in=targets) print creators url_number = len(Sitemail.objects) + 1 mail = Sitemail( title=title, content=content, creator=creators, creat_time=datetime.datetime.now(), is_readed=False, url_number=url_number, ).save() return HttpResponseRedirect("/sitemail/outbox/") else: form = NewMailForm() return render_to_response( "sitemail/sendmail.html", {"STATIC_URL": STATIC_URL, "current_user": request.user, "form": form}, context_instance=RequestContext(request), )
def get_sscard_as_target(self): from relations.models import S_S_Card return S_S_Card.objects(target=self)
def get_sscard_as_user(self): from relations.models import S_S_Card return S_S_Card.objects(user=self)
def cancle_watch_student(request, url_number): current_user = request.user student = Student.objects(url_number=url_number).get() S_S_Card.objects(user=current_user, target=student).delete() return HttpResponse('success')
def get_watchpeople(self): from relations.models import S_S_Card return S_S_Card.objects(user=self).scalar('target')
def get_fans(self): from relations.models import S_S_Card return S_S_Card.objects(target=self).scalar('user')