예제 #1
0
    def action_view(self, http_request, selected_instances):
        members = selected_instances
        if http_request.method == 'POST':
            form = MemberSendMessageForm(http_request.POST,
                                         http_request=http_request)
            if form.is_valid():
                subject = form.cleaned_data.get('subject')
                body = form.cleaned_data.get('body')
                is_sms = form.cleaned_data.get('is_sms')
                is_mail = form.cleaned_data.get('is_mail')
                receivers = [member.user for member in members]
                Message.send_message(http_request.user,
                                     u"پیام دریافتی از مدیریت سیستم", body,
                                     receivers)
                if is_mail:
                    receivers_mail = [user.email for user in receivers]
                    message_text = MessageServices.get_send_message(
                        http_request.user, subject, body)
                    MessageServices.send_mass_message(subject, message_text,
                                                      receivers_mail)
                if is_sms:
                    mobiles = [member.mobile for member in members]
                    if mobiles:
                        SMSService.send_sms(subject + '\n' + body, mobiles)
                form = None
                messages.success(http_request, u"پیام شما با موفقیت انجام شد.")
        else:
            form = MemberSendMessageForm(http_request=http_request)

        return render_to_response(
            'manager/actions/add_edit.html', {
                'form': form,
                'title': u"ارسال پیام"
            },
            context_instance=RequestContext(http_request))
예제 #2
0
    def action_view(self, http_request, selected_instances):
        members = selected_instances
        if http_request.method == 'POST':
            form = MemberSendMessageForm(http_request.POST, http_request=http_request)
            if form.is_valid():
                subject = form.cleaned_data.get('subject')
                body = form.cleaned_data.get('body')
                is_sms = form.cleaned_data.get('is_sms')
                is_mail = form.cleaned_data.get('is_mail')
                receivers = [member.user for member in members]
                Message.send_message(http_request.user, u"پیام دریافتی از مدیریت سیستم", body, receivers)
                if is_mail:
                    receivers_mail = [user.email for user in receivers]
                    message_text = MessageServices.get_send_message(http_request.user, subject, body)
                    MessageServices.send_mass_message(subject, message_text, receivers_mail)
                if is_sms:
                    mobiles = [member.mobile for member in members]
                    if mobiles:
                        SMSService.send_sms(subject + '\n' + body, mobiles)
                form = None
                messages.success(http_request, u"پیام شما با موفقیت انجام شد.")
        else:
            form = MemberSendMessageForm(http_request=http_request)

        return render_to_response('manager/actions/add_edit.html', {'form': form, 'title': u"ارسال پیام"},
                                  context_instance=RequestContext(http_request))
예제 #3
0
파일: models.py 프로젝트: hamed1369/Cluster
    def check_milestones(cls):
        import datetime
        from cluster.message.models import Message

        two_days_later = datetime.date.today() + datetime.timedelta(days=2)
        milestones = ProjectMilestone.objects.filter(milestone_date__lte=two_days_later, is_announced=False)
        body = u"""
        موعد های طرح های زیر گذشته اند یا نزدیک هستند:
        """
        i = 1
        if not milestones:
            return

        admin_users = PermissionController.get_admins()

        for milestone in milestones:
            receiver = (
                milestone.project.single_member.user
                if milestone.project.single_member
                else milestone.project.cluster.head.user
            )
            receiver_mobile = (
                milestone.project.single_member.mobile
                if milestone.project.single_member
                else milestone.project.cluster.head.mobile
            )
            section = u"""
                 موعد  %s  مربوط به طرح %s  برای زمان  %s
            """ % (
                milestone.comment,
                milestone.project.title,
                gregorian_to_jalali(milestone.milestone_date),
            )
            Message.send_message(admin_users[0], title=u"موعدهای گذشته یا نزدیک", body=body, receivers=[receiver])
            message = MessageServices.get_title_body_message(title=u"موعد طرح زیر گذشته یا نزدیک است:", body=section)
            MessageServices.send_message(subject=u"موعد طرح", message=message, user=receiver)
            SMSService.send_sms(
                message=u"موعد طرح زیر گذشته یا نزدیک است:" + "\n" + section, to_numbers=[receiver_mobile]
            )
            body += "\n" + unicode(i) + u"- " + section.strip()
            i += 1
            milestone.is_announced = True
            milestone.save()
            if milestone.project.supervisor:
                MessageServices.send_message(
                    subject=u"موعد طرح", message=message, user=milestone.project.supervisor.user
                )

        # message = MessageServices.get_title_body_message(title=u"موعد های طرح های زیر گذشته اند یا نزدیک هستند:",
        #                                                 body=body)
        Message.send_message(admin_users[0], title=u"موعدهای گذشته یا نزدیک", body=body, receivers=admin_users)
예제 #4
0
    def check_milestones(cls):
        import datetime
        from cluster.message.models import Message

        two_days_later = datetime.date.today() + datetime.timedelta(days=2)
        milestones = ProjectMilestone.objects.filter(
            milestone_date__lte=two_days_later, is_announced=False)
        body = u"""
        موعد های طرح های زیر گذشته اند یا نزدیک هستند:
        """
        i = 1
        if not milestones:
            return

        admin_users = PermissionController.get_admins()

        for milestone in milestones:
            receiver = milestone.project.single_member.user if milestone.project.single_member else milestone.project.cluster.head.user
            receiver_mobile = milestone.project.single_member.mobile if milestone.project.single_member else milestone.project.cluster.head.mobile
            section = u"""
                 موعد  %s  مربوط به طرح %s  برای زمان  %s
            """ % (milestone.comment, milestone.project.title,
                   gregorian_to_jalali(milestone.milestone_date))
            Message.send_message(admin_users[0],
                                 title=u"موعدهای گذشته یا نزدیک",
                                 body=body,
                                 receivers=[receiver])
            message = MessageServices.get_title_body_message(
                title=u"موعد طرح زیر گذشته یا نزدیک است:", body=section)
            MessageServices.send_message(subject=u"موعد طرح",
                                         message=message,
                                         user=receiver)
            SMSService.send_sms(message=u"موعد طرح زیر گذشته یا نزدیک است:" +
                                '\n' + section,
                                to_numbers=[receiver_mobile])
            body += '\n' + unicode(i) + u'- ' + section.strip()
            i += 1
            milestone.is_announced = True
            milestone.save()
            if milestone.project.supervisor:
                MessageServices.send_message(
                    subject=u"موعد طرح",
                    message=message,
                    user=milestone.project.supervisor.user)

        #message = MessageServices.get_title_body_message(title=u"موعد های طرح های زیر گذشته اند یا نزدیک هستند:",
        #                                                 body=body)
        Message.send_message(admin_users[0],
                             title=u"موعدهای گذشته یا نزدیک",
                             body=body,
                             receivers=admin_users)