Code Duplication    Length = 16-22 lines in 2 locations

chat/models.py 2 locations

@@ 243-264 (lines=22) @@
240
		self.type = p_type.value
241
242
243
class Image(models.Model):
244
245
	class MediaTypeChoices(Enum):
246
		video = 'v'
247
		image = 'i'
248
249
	# character in Message.content that will be replaced with this image
250
	symbol = models.CharField(null=False, max_length=1)
251
	message = models.ForeignKey(Message, related_name='message', null=False)
252
	img = FileField(upload_to=get_random_path, null=True)
253
	type = models.CharField(null=False, max_length=1, default=MediaTypeChoices.image.value)
254
255
	@property
256
	def type_enum(self):
257
		return MediaTypeChoices(self.type)
258
259
	@type_enum.setter
260
	def type_enum(self, p_type):
261
		self.type = p_type.value
262
263
	class Meta:
264
		unique_together = ('symbol', 'message')
265
266
267
class RoomUsers(models.Model):
@@ 225-240 (lines=16) @@
222
		return "{}/{}".format(self.id, v)
223
224
225
class UploadedFile(models.Model):
226
	class UploadedFileChoices(Enum):
227
		video = 'v'
228
		image = 'i'
229
	symbol = models.CharField(null=False, max_length=1)
230
	file = FileField(upload_to=get_random_path, null=True)
231
	user = models.ForeignKey(User, null=False)
232
	type = models.CharField(null=False, max_length=1)
233
234
	@property
235
	def type_enum(self):
236
		return UploadedFileChoices(self.type)
237
238
	@type_enum.setter
239
	def type_enum(self, p_type):
240
		self.type = p_type.value
241
242
243
class Image(models.Model):