Example #1
0
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))
Example #2
0
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),
        )
Example #3
0
 def get_sscard_as_target(self):
     from relations.models import S_S_Card
     return S_S_Card.objects(target=self)
Example #4
0
 def get_sscard_as_user(self):
     from relations.models import S_S_Card
     return S_S_Card.objects(user=self)
Example #5
0
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')
Example #6
0
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')
Example #7
0
 def get_sscard_as_target(self):
     from relations.models import S_S_Card
     return S_S_Card.objects(target=self)
Example #8
0
 def get_sscard_as_user(self):
     from relations.models import S_S_Card
     return S_S_Card.objects(user=self)
Example #9
0
 def get_watchpeople(self):
     from relations.models import S_S_Card
     return S_S_Card.objects(user=self).scalar('target')
Example #10
0
 def get_fans(self):
     from relations.models import S_S_Card
     return S_S_Card.objects(target=self).scalar('user')