Code Duplication    Length = 57-58 lines in 2 locations

backend/tracim_backend/lib/webdav/resources.py 2 locations

@@ 821-878 (lines=58) @@
818
819
        return retlist
820
821
    def getMemberList(self) -> [_DAVResource]:
822
        members = []
823
824
        if self.content:
825
            children = self.content.children
826
        else:
827
            children = self.content_api.get_all(False, CONTENT_TYPES.Any_SLUG, self.workspace)
828
829
        for content in children:
830
            if content.is_deleted:
831
                content_path = '%s/%s' % (self.path, transform_to_display(content.get_label_as_file()))
832
833
                if content.type == CONTENT_TYPES.Folder.slug:
834
                    members.append(
835
                        FolderResource(
836
                            content_path,
837
                            self.environ,
838
                            self.workspace,
839
                            content,
840
                            user=self.user,
841
                            session=self.session,
842
                        ))
843
                elif content.type == CONTENT_TYPES.File.slug:
844
                    self._file_count += 1
845
                    members.append(
846
                        FileResource(
847
                            content_path,
848
                            self.environ,
849
                            content,
850
                            user=self.user,
851
                            session=self.session,
852
                        )
853
                    )
854
                else:
855
                    self._file_count += 1
856
                    members.append(
857
                        OtherFileResource(
858
                            content_path,
859
                            self.environ,
860
                            content,
861
                            user=self.user,
862
                            session=self.session,
863
                    ))
864
865
        if self._file_count > 0 and self.provider.show_history():
866
            members.append(
867
                HistoryFolderResource(
868
                    path=self.path + '/' + ".history",
869
                    environ=self.environ,
870
                    content=self.content,
871
                    workspace=self.workspace,
872
                    user=self.user,
873
                    type=HistoryType.Standard,
874
                    session=self.session,
875
                )
876
            )
877
878
        return members
879
880
881
class ArchivedFolderResource(HistoryFolderResource):
@@ 942-998 (lines=57) @@
939
940
        return retlist
941
942
    def getMemberList(self) -> [_DAVResource]:
943
        members = []
944
945
        if self.content:
946
            children = self.content.children
947
        else:
948
            children = self.content_api.get_all(False, CONTENT_TYPES.Any_SLUG, self.workspace)
949
950
        for content in children:
951
            if content.is_archived:
952
                content_path = '%s/%s' % (self.path, transform_to_display(content.get_label_as_file()))
953
954
                if content.type == CONTENT_TYPES.Folder.slug:
955
                    members.append(
956
                        FolderResource(
957
                            content_path,
958
                            self.environ,
959
                            self.workspace,
960
                            content,
961
                            user=self.user,
962
                            session=self.session,
963
                        ))
964
                elif content.type == CONTENT_TYPES.File.slug:
965
                    self._file_count += 1
966
                    members.append(
967
                        FileResource(
968
                            content_path,
969
                            self.environ,
970
                            content,
971
                            user=self.user,
972
                            session=self.session,
973
                        ))
974
                else:
975
                    self._file_count += 1
976
                    members.append(
977
                        OtherFileResource(
978
                            content_path,
979
                            self.environ,
980
                            content,
981
                            user=self.user,
982
                            session=self.session,
983
                        ))
984
985
        if self._file_count > 0 and self.provider.show_history():
986
            members.append(
987
                HistoryFolderResource(
988
                    path=self.path + '/' + ".history",
989
                    environ=self.environ,
990
                    content=self.content,
991
                    workspace=self.workspace,
992
                    user=self.user,
993
                    type=HistoryType.Standard,
994
                    session=self.session,
995
                )
996
            )
997
998
        return members
999
1000
1001
class HistoryFileFolderResource(HistoryFolderResource):