1. Victor Gavro
  2. django-smsgate

Commits

Victor Gavro  committed 9d23541

Added message on sent created message at admin page

  • Participants
  • Parent commits b5ce235
  • Branches default

Comments (0)

Files changed (5)

File smsgate/admin.py

View file
  • Ignore whitespace
-from django.contrib import admin
 from smsgate.models import Sms,SmsRecipient
 from smsgate import settings
+from django.contrib import admin
 from django.utils.translation import ugettext_lazy as _
+from django.contrib import messages
 
 def sms_send_queued(self, request, queryset):
   for sms in queryset:
     instances = formset.save()
     if settings.SEND_ON_SAVE and instances:
       instances[0].sms.send()
+    messages.info(request,_('SMS sent to %s recipients'))
 
 def sms_recipient_get_status(self, request, queryset):
   count = SmsRecipient.get_statuses(recipients=queryset)

File smsgate/locale/ru_RU/LC_MESSAGES/django.mo

  • Ignore whitespace
Binary file modified.

File smsgate/locale/ru_RU/LC_MESSAGES/django.po

View file
  • Ignore whitespace
 msgstr ""
 "Project-Id-Version: django-smsgate\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2010-09-17 07:49+0300\n"
-"PO-Revision-Date: 2010-09-17 07:51+0300\n"
+"POT-Creation-Date: 2010-09-17 08:08+0300\n"
+"PO-Revision-Date: 2010-09-17 08:08+0300\n"
 "Last-Translator: Victor Gavro <vgavro@gmail.com>\n"
 "Language-Team: \n"
 "Language: \n"
 "Content-Transfer-Encoding: 8bit\n"
 "X-Poedit-Language: Russian\n"
 
-#: admin.py:9
-#: admin.py:36
+#: admin.py:10
+#: admin.py:38
 #, python-format
 msgid "%s SMS messages sent"
 msgstr "Отправлено SMS сообщений: %s"
 
-#: admin.py:10
+#: admin.py:11
 msgid "Send SMS to queued recipients"
 msgstr "Отправить SMS получателям в очереди"
 
-#: admin.py:30
+#: admin.py:28
+#, python-format
+msgid "SMS sent to %s recipients"
+msgstr "SMS отправлено получателям: %s"
+
+#: admin.py:32
 #, python-format
 msgid "%s SMS statuses fetched"
 msgstr "Получено обновлений статуса SMS: %s"
 
-#: admin.py:31
+#: admin.py:33
 msgid "Retrieve SMS current status"
 msgstr "Обновить статус SMS"
 
-#: admin.py:37
+#: admin.py:39
 msgid "Resend SMS to recipient"
 msgstr "Переслать SMS получателю"
 
 msgid "SMS messages"
 msgstr "SMS сообщения"
 
-#: models.py:42
+#: models.py:47
 msgid "Total recipients"
 msgstr "Всего получателей"
 
-#: models.py:46
+#: models.py:51
 msgid "Successed recipients"
 msgstr "Успешных получателей"
 
-#: models.py:90
+#: models.py:95
 msgid "Queued"
 msgstr "В очереди"
 
-#: models.py:91
+#: models.py:96
 msgid "Canceled"
 msgstr "Отменено"
 
-#: models.py:92
+#: models.py:97
 msgid "Sent"
 msgstr "Отправлено"
 
-#: models.py:93
+#: models.py:98
 msgid "Not sent"
 msgstr "Не отправлено"
 
-#: models.py:94
+#: models.py:99
 msgid "Unknown"
 msgstr "Неизвестно"
 
-#: models.py:95
+#: models.py:100
 msgid "Queued on server"
 msgstr "В очереди (на сервере)"
 
-#: models.py:96
+#: models.py:101
 msgid "Delivered"
 msgstr "Доставлено"
 
-#: models.py:97
+#: models.py:102
 msgid "Undelivered"
 msgstr "Недоставлено"
 
-#: models.py:98
+#: models.py:103
 msgid "Expired"
 msgstr "Срок истек"
 
-#: models.py:100
+#: models.py:105
 msgid "Phone number"
 msgstr "Телефонный номер"
 
-#: models.py:101
+#: models.py:106
 msgid "Remote id"
 msgstr "Удаленный ID"
 
-#: models.py:102
-#: models.py:146
+#: models.py:107
+#: models.py:151
 msgid "Status"
 msgstr "Статус"
 
-#: models.py:103
+#: models.py:108
 msgid "Queued time"
 msgstr "Постановлено в очередь"
 
-#: models.py:104
+#: models.py:109
 msgid "Status renew time"
 msgstr "Обновлен статус"
 
-#: models.py:105
+#: models.py:110
 msgid "Sent time"
 msgstr "Отправлено"
 
-#: models.py:106
-#: models.py:152
+#: models.py:111
+#: models.py:157
 msgid "Status message"
 msgstr "Доп. сообщение"
 
-#: models.py:107
+#: models.py:112
 msgid "Credits"
 msgstr "Кредиты"
 
-#: models.py:111
+#: models.py:116
 msgid "SMS recipient"
 msgstr "SMS получатель"
 
-#: models.py:112
+#: models.py:117
 msgid "SMS recipients"
 msgstr "SMS получатели"
 

File smsgate/models.py

View file
  • Ignore whitespace
     verbose_name_plural = _('SMS messages')
 
   def send(self,statuses=(STATUS_QUEUED,),recipients=None):
+    '''Sending message to recipients.
+    If recipients is not specified - fetching recipients with status in statuses argument.
+    Returns count of sent recipients.
+    '''
     if recipients == None:
       recipients = self.recipients.filter(status__in=statuses)
     sent_data = send_sms(
     )
     for n,(remote_id,status,status_text) in enumerate(sent_data):
       recipients[n].set_processed(remote_id,status,status_text,save=True)
+    return len(sent_data)
 
   def recipients_count(self):
     return self.recipients.all().count()

File smsgate_test/test.db

  • Ignore whitespace
Binary file modified.