예제 #1
0
파일: views.py 프로젝트: raeesaroj/mole
 def get_success_url(self):
     converter = NepaliDateConverter()
     self.object.dateupdated = converter.ad2bs((datetime.date.today().year, datetime.date.today().month, datetime.date.today().day))
     if self.object.datesubmited is None:
         self.object.datesubmited = converter.ad2bs((datetime.date.today().year, datetime.date.today().month, datetime.date.today().day))
     self.object.save()
     return reverse('sachibBaithak:sachibbaithak-main-list', args=(self.object.office.id,))
예제 #2
0
파일: views.py 프로젝트: raeesaroj/mole
 def get_success_url(self):
     converter = NepaliDateConverter()
     self.object.dateupdated = converter.ad2bs(
         (datetime.date.today().year, datetime.date.today().month,
          datetime.date.today().day))
     if self.object.datesubmited is None:
         self.object.datesubmited = converter.ad2bs(
             (datetime.date.today().year, datetime.date.today().month,
              datetime.date.today().day))
     self.object.save()
     return reverse('karyasampadan:monthly-all-progress-list',
                    args=(self.object.sampadankaryakram.office.id,
                          self.object.sampadankaryakram.id))
예제 #3
0
파일: views.py 프로젝트: raeesaroj/mole
 def form_valid(self, form):
     super(SachibBaithakMainCreateView, self).form_valid(form)
     form.instance.office = Office.objects.get(pk=self.kwargs.get('office'),)
     converter = NepaliDateConverter()
     form.instance.datesubmited = converter.ad2bs((datetime.date.today().year, datetime.date.today().month, datetime.date.today().day))
     self.object = form.save()
     return redirect(reverse('sachibBaithak:sachibbaithak-main-list', args=(self.object.office.id,)))
 def form_valid(self, form):
     form.instance.sachibbaithakmain_id = self.kwargs.get('main_id')
     converter = NepaliDateConverter()
     form.instance.datesubmited = converter.ad2bs(
         (datetime.date.today().year, datetime.date.today().month,
          datetime.date.today().day))
     self.object = form.save()
     return redirect(
         reverse('sachibBaithak:sachibbaithak-list',
                 args=(self.kwargs.get('office'),
                       self.kwargs.get('main_id'))))
 def form_valid(self, form):
     form.instance.office = Office.objects.get(
         pk=self.kwargs.get('office'), )
     converter = NepaliDateConverter()
     form.instance.datesubmited = converter.ad2bs(
         (datetime.date.today().year, datetime.date.today().month,
          datetime.date.today().day))
     self.object = form.save()
     return redirect(
         reverse('sachibBaithak:budgetbaktabya-list',
                 args=(self.object.office.id, )))
    def post(self, request, *args, **kwargs):
        com = Comments()
        a = request.user
        com.comment = request.POST.get('comment')
        com.comment_obj = KaryaKram.objects.get(pk=request.POST.get('k_id'))
        com.commented_by = request.user
        converter = NepaliDateConverter()
        com.date_commented = converter.ad2bs(
            (datetime.date.today().year, datetime.date.today().month,
             datetime.date.today().day))
        com.save()

        if request.group.id == 4:
            recipients = User.objects.filter(
                user_roles__group__name="Office Head",
                user_roles__office__id=com.comment_obj.office.id)
            group = "office_head-" + str(com.comment_obj.office.id)
        else:
            recipients = User.objects.filter(
                user_roles__group__name="Information Officer",
                user_roles__office__id=com.comment_obj.office.id)
            group = "info_officer-" + str(com.comment_obj.office.id)

        notify.send(request.user,
                    recipient=recipients,
                    verb='commented on',
                    action_object=com.comment_obj,
                    detail_url='/comment/add/22/')

        Group("%s" % group).send({
            'text':
            json.dumps({
                'by': str(request.user),
                'verb': "commented on",
                'time': "Just Now",
                'detail_url': "/comment/add/22/",
                'action_object': str(com.comment_obj),
            })
        })

        html = render_to_string(
            'ajax_temp/ajaxcomments.html', {
                'comments':
                Comments.objects.filter(
                    comment_obj_object_id=request.POST.get('k_id'),
                    comment_obj_content_type=ContentType.objects.get_for_model(
                        KaryaKram))
            })
        return HttpResponse(html)