@@ -18,18 +18,18 @@ def __call__(
1818 self ,
1919 storage : tuple [str , list , dict ],
2020 file_name : str ,
21+ sender : tuple [str , str , str ],
2122 new : list [tuple [str , list , dict ]] | None = None ,
2223 old : list [tuple [str , list , dict ]] | None = None ,
23- field : str = "" ,
2424 ) -> None : ...
2525
2626
2727def _process_picture (
2828 storage : tuple [str , list , dict ],
2929 file_name : str ,
30+ sender : tuple [str , str , str ],
3031 new : list [tuple [str , list , dict ]] | None = None ,
3132 old : list [tuple [str , list , dict ]] | None = None ,
32- field : str = "" ,
3333) -> None :
3434 new = new or []
3535 old = old or []
@@ -44,19 +44,15 @@ def _process_picture(
4444 picture = utils .reconstruct (* picture )
4545 picture .delete ()
4646
47- if field :
48- app_label , model_name , _ = field .split ("." )
49- sender = apps .get_model (app_label = app_label , model_name = model_name )
50- else :
51- sender = _process_picture
47+ app_label , model_name , field_name = sender
48+ model = apps .get_model (app_label = app_label , model_name = model_name )
49+ field = model ._meta .get_field (field_name )
5250
53- signals .process_picture_done .send (
54- sender = sender ,
55- storage = storage .deconstruct (),
51+ signals .picture_processed .send (
52+ sender = field ,
5653 file_name = file_name ,
5754 new = new ,
5855 old = old ,
59- field = field ,
6056 )
6157
6258
@@ -73,26 +69,26 @@ def _process_picture(
7369 def process_picture_with_dramatiq (
7470 storage : tuple [str , list , dict ],
7571 file_name : str ,
72+ sender : tuple [str , str , str ],
7673 new : list [tuple [str , list , dict ]] | None = None ,
7774 old : list [tuple [str , list , dict ]] | None = None ,
78- field : str = "" ,
7975 ) -> None :
80- _process_picture (storage , file_name , new , old , field )
76+ _process_picture (storage , file_name , sender , new , old )
8177
8278 def process_picture ( # noqa: F811
8379 storage : tuple [str , list , dict ],
8480 file_name : str ,
81+ sender : tuple [str , str , str ],
8582 new : list [tuple [str , list , dict ]] | None = None ,
8683 old : list [tuple [str , list , dict ]] | None = None ,
87- field : str = "" ,
8884 ) -> None :
8985 transaction .on_commit (
9086 lambda : process_picture_with_dramatiq .send (
9187 storage = storage ,
9288 file_name = file_name ,
89+ sender = sender ,
9390 new = new ,
9491 old = old ,
95- field = field ,
9692 )
9793 )
9894
@@ -110,27 +106,27 @@ def process_picture( # noqa: F811
110106 def process_picture_with_celery (
111107 storage : tuple [str , list , dict ],
112108 file_name : str ,
109+ sender : tuple [str , str , str ],
113110 new : list [tuple [str , list , dict ]] | None = None ,
114111 old : list [tuple [str , list , dict ]] | None = None ,
115- field : str = "" ,
116112 ) -> None :
117- _process_picture (storage , file_name , new , old , field )
113+ _process_picture (storage , file_name , sender , new , old )
118114
119115 def process_picture ( # noqa: F811
120116 storage : tuple [str , list , dict ],
121117 file_name : str ,
118+ sender : tuple [str , str , str ],
122119 new : list [tuple [str , list , dict ]] | None = None ,
123120 old : list [tuple [str , list , dict ]] | None = None ,
124- field : str = "" ,
125121 ) -> None :
126122 transaction .on_commit (
127123 lambda : process_picture_with_celery .apply_async (
128124 kwargs = dict (
129125 storage = storage ,
130126 file_name = file_name ,
127+ sender = sender ,
131128 new = new ,
132129 old = old ,
133- field = field ,
134130 ),
135131 queue = conf .get_settings ().QUEUE_NAME ,
136132 )
@@ -147,25 +143,25 @@ def process_picture( # noqa: F811
147143 def process_picture_with_django_rq (
148144 storage : tuple [str , list , dict ],
149145 file_name : str ,
146+ sender : tuple [str , str , str ],
150147 new : list [tuple [str , list , dict ]] | None = None ,
151148 old : list [tuple [str , list , dict ]] | None = None ,
152- field : str = "" ,
153149 ) -> None :
154- _process_picture (storage , file_name , new , old , field )
150+ _process_picture (storage , file_name , sender , new , old )
155151
156152 def process_picture ( # noqa: F811
157153 storage : tuple [str , list , dict ],
158154 file_name : str ,
155+ sender : tuple [str , str , str ],
159156 new : list [tuple [str , list , dict ]] | None = None ,
160157 old : list [tuple [str , list , dict ]] | None = None ,
161- field : str = "" ,
162158 ) -> None :
163159 transaction .on_commit (
164160 lambda : process_picture_with_django_rq .delay (
165161 storage = storage ,
166162 file_name = file_name ,
163+ sender = sender ,
167164 new = new ,
168165 old = old ,
169- field = field ,
170166 )
171167 )
0 commit comments