示例#1
0
文件: signals.py 项目: h3l/hexyou
def activity_inform(sender,**kwargs):
    if not kwargs['instance'].accepted:
        return
    subject = u"[活动]"+ kwargs['instance'].activity.title + u" " + kwargs['instance'].activity.get_host_string(False)
    t = get_template('activities/create_inform.html')
    body = t.render(Context({'activity':kwargs['instance'].activity}))
    for member in kwargs['instance'].group.members.all():
        inform(subject,body,member)
示例#2
0
文件: views.py 项目: h3l/hexyou
def create(request):
    location_roots = Location.objects.filter(parent=None)
    if request.POST:
        form=ActivityForm(request.POST)
        if form.is_valid():
            activity = form.save(commit=False)
            activity.save()
            memberhost = MemberHostShip(is_host=True,activity=activity,user=request.user)
            memberhost.save()
            for host_group in form.cleaned_data['host_groups']:
                group = Group.objects.get(pk=host_group)
                hostship = HostShip(activity=activity,group=group)
                if MemberShip.objects.get(group=group,user=request.user).is_admin:
                    hostship.accepted = True
                hostship.save()
            subject = u"[活动]"+ activity.title + u" " + activity.get_host_string(False)
            t = get_template('activities/create_inform.html')
            body = t.render(Context({'activity':activity}))
            for member in form.cleaned_data['inform_users']:
                inform(subject,body,User.objects.get(pk=member))
            return redirect("/activities/%s" % activity.id)
    else:
        form=ActivityForm()
    return render_to_response('activities/host.html', {'form':form,'location_roots':location_roots}, context_instance=RequestContext(request))
示例#3
0
文件: views.py 项目: h3l/hexyou
def group_inform(group, user):
    subject = u"[组织]" + group.name + u" 邀请您加入"
    t = get_template("groups/inform.html")
    body = t.render(Context({"group": group}))
    inform(subject, body, user)