@ -12,9 +12,9 @@ import io
import time
import time
import logging
import logging
from . models import Entity , Prospect , Activity , Status , ActivityType , EmailTemplate , DeclinationReason
from . models import Entity , Prospect , Activity , Status , ActivityType , EmailTemplate , DeclinationReason , ProspectGroup
from . forms import FileImportForm , EmailTemplateSelectionForm
from . forms import FileImportForm , EmailTemplateSelectionForm
from . filters import ContactAgainFilter , ProspectStatusFilter , StaffUserFilter , ProspectProfileFilter , ProspectDeclineReasonFilter
from . filters import ContactAgainFilter , ProspectStatusFilter , StaffUserFilter , ProspectProfileFilter , ProspectDeclineReasonFilter , ProspectGroupFilter
from tournaments . models import CustomUser
from tournaments . models import CustomUser
from tournaments . models . enums import UserOrigin
from tournaments . models . enums import UserOrigin
@ -75,6 +75,10 @@ def declined_android_user(modeladmin, request, queryset):
create_default_activity_for_prospect ( modeladmin , request , queryset , None , Status . DECLINED , DeclinationReason . USE_ANDROID )
create_default_activity_for_prospect ( modeladmin , request , queryset , None , Status . DECLINED , DeclinationReason . USE_ANDROID )
declined_android_user . short_description = " Declined use Android "
declined_android_user . short_description = " Declined use Android "
def mark_as_have_account ( modeladmin , request , queryset ) :
create_default_activity_for_prospect ( modeladmin , request , queryset , None , Status . HAVE_CREATED_ACCOUNT , None )
mark_as_have_account . short_description = " Mark as having an account "
def create_default_activity_for_prospect ( modeladmin , request , queryset , type , status , reason ) :
def create_default_activity_for_prospect ( modeladmin , request , queryset , type , status , reason ) :
for prospect in queryset :
for prospect in queryset :
activity = Activity . objects . create (
activity = Activity . objects . create (
@ -114,13 +118,13 @@ class ProspectAdmin(SyncedObjectAdmin):
]
]
list_display = ( ' first_name ' , ' last_name ' , ' entity_names ' , ' last_update_date ' , ' current_status ' , ' current_text ' , ' contact_again ' )
list_display = ( ' first_name ' , ' last_name ' , ' entity_names ' , ' last_update_date ' , ' current_status ' , ' current_text ' , ' contact_again ' )
list_filter = ( ContactAgainFilter , ProspectStatusFilter , ProspectDeclineReasonFilter , ' creation_date ' , StaffUserFilter , ' source ' , ProspectProfileFilter )
list_filter = ( ContactAgainFilter , ProspectStatusFilter , ProspectDeclineReasonFilter , ProspectGroupFilter , ' creation_date ' , StaffUserFilter , ' source ' , ProspectProfileFilter )
search_fields = ( ' first_name ' , ' last_name ' , ' email ' , ' entities__name ' )
search_fields = ( ' first_name ' , ' last_name ' , ' email ' , ' entities__name ' )
date_hierarchy = ' creation_date '
date_hierarchy = ' creation_date '
change_list_template = " admin/biz/prospect/change_list.html "
change_list_template = " admin/biz/prospect/change_list.html "
ordering = [ ' -last_update ' ]
ordering = [ ' -last_update ' ]
filter_horizontal = [ ' entities ' ]
filter_horizontal = [ ' entities ' ]
actions = [ ' send_email ' , create_activity_for_prospect , mark_as_inbound , contacted_by_sms , mark_as_should_test , mark_as_testing , mark_as_customer , declined_too_expensive , declined_use_something_else , declined_android_user ]
actions = [ ' send_email ' , create_activity_for_prospect , mark_as_inbound , contacted_by_sms , mark_as_should_test , mark_as_testing , mark_as_customer , mark_as_have_account , declined_too_expensive , declined_use_something_else , declined_android_user ]
raw_id_fields = [ ' official_user ' , ' related_user ' ]
raw_id_fields = [ ' official_user ' , ' related_user ' ]
def last_update_date ( self , obj ) :
def last_update_date ( self , obj ) :
@ -397,6 +401,10 @@ class ProspectAdmin(SyncedObjectAdmin):
time . sleep ( 1 )
time . sleep ( 1 )
@admin . register ( ProspectGroup )
class ProspectGroupAdmin ( SyncedObjectAdmin ) :
list_display = ( ' name ' , ' user_count ' )
date_hierarchy = ' creation_date '
@admin . register ( Activity )
@admin . register ( Activity )
class ActivityAdmin ( SyncedObjectAdmin ) :
class ActivityAdmin ( SyncedObjectAdmin ) :
@ -429,57 +437,3 @@ class ActivityAdmin(SyncedObjectAdmin):
def get_event_display ( self , obj ) :
def get_event_display ( self , obj ) :
return str ( obj )
return str ( obj )
get_event_display . short_description = ' Activity '
get_event_display . short_description = ' Activity '
# @admin.register(EmailCampaign)
# class EmailCampaignAdmin(admin.ModelAdmin):
# list_display = ('subject', 'event', 'sent_at')
# list_filter = ('sent_at',)
# search_fields = ('subject', 'content')
# date_hierarchy = 'sent_at'
# readonly_fields = ('sent_at',)
# @admin.register(EmailTracker)
# class EmailTrackerAdmin(admin.ModelAdmin):
# list_display = (
# 'campaign',
# 'prospect',
# 'tracking_id',
# 'sent_status',
# 'opened_status',
# 'clicked_status'
# )
# list_filter = ('sent', 'opened', 'clicked')
# search_fields = (
# 'prospect__name',
# 'prospect__email',
# 'campaign__subject'
# )
# readonly_fields = (
# 'tracking_id', 'sent', 'sent_at',
# 'opened', 'opened_at',
# 'clicked', 'clicked_at'
# )
# date_hierarchy = 'sent_at'
# def sent_status(self, obj):
# return self._get_status_html(obj.sent, obj.sent_at)
# sent_status.short_description = 'Sent'
# sent_status.allow_tags = True
# def opened_status(self, obj):
# return self._get_status_html(obj.opened, obj.opened_at)
# opened_status.short_description = 'Opened'
# opened_status.allow_tags = True
# def clicked_status(self, obj):
# return self._get_status_html(obj.clicked, obj.clicked_at)
# clicked_status.short_description = 'Clicked'
# clicked_status.allow_tags = True
# def _get_status_html(self, status, date):
# if status:
# return format_html(
# '<span style="color: green;">✓</span> {}',
# date.strftime('%Y-%m-%d %H:%M') if date else ''
# )
# return format_html('<span style="color: red;">✗</span>')