Browse Source

runtime: proposals: Remove post editions.

Shamil Gadelshin 4 years ago
parent
commit
ccf03854f2

+ 0 - 2
runtime-modules/proposals/codex/src/tests/mock.rs

@@ -123,7 +123,6 @@ impl common::origin::ActorOriginValidator<Origin, u64, u64> for () {
 }
 
 parameter_types! {
-    pub const MaxPostEditionNumber: u32 = 5;
     pub const MaxThreadInARowNumber: u32 = 3;
     pub const ThreadTitleLengthLimit: u32 = 200;
     pub const PostLengthLimit: u32 = 2000;
@@ -136,7 +135,6 @@ impl proposals_discussion::Trait for Test {
     type CouncilOriginValidator = ();
     type ThreadId = u64;
     type PostId = u64;
-    type MaxPostEditionNumber = MaxPostEditionNumber;
     type MaxThreadInARowNumber = MaxThreadInARowNumber;
     type MaxWhiteListSize = MaxWhiteListSize;
 }

+ 0 - 18
runtime-modules/proposals/discussion/src/lib.rs

@@ -108,9 +108,6 @@ pub trait Trait: system::Trait + membership::Trait {
     /// Post Id type
     type PostId: From<u64> + Parameter + Default + Copy;
 
-    /// Defines post edition number limit.
-    type MaxPostEditionNumber: Get<u32>;
-
     /// Defines max thread by same author in a row number limit.
     type MaxThreadInARowNumber: Get<u32>;
 
@@ -124,9 +121,6 @@ decl_error! {
         /// Author should match the post creator
         NotAuthor,
 
-        ///  Post edition limit reached
-        PostEditionNumberExceeded,
-
         /// Thread doesn't exist
         ThreadDoesntExist,
 
@@ -183,9 +177,6 @@ decl_module! {
         /// Emits an event. Default substrate implementation.
         fn deposit_event() = default;
 
-        /// Exports post edition number limit const.
-        const MaxPostEditionNumber: u32 = T::MaxPostEditionNumber::get();
-
         /// Exports max thread by same author in a row number limit const.
         const MaxThreadInARowNumber: u32 = T::MaxThreadInARowNumber::get();
 
@@ -213,7 +204,6 @@ decl_module! {
 
             let new_post = DiscussionPost {
                 author_id: post_author_id,
-                edition_number : 0,
             };
 
             let post_id = T::PostId::from(new_post_id);
@@ -242,17 +232,9 @@ decl_module! {
             let post = <PostThreadIdByPostId<T>>::get(&thread_id, &post_id);
 
             ensure!(post.author_id == post_author_id, Error::<T>::NotAuthor);
-            ensure!(post.edition_number < T::MaxPostEditionNumber::get(),
-                Error::<T>::PostEditionNumberExceeded);
-
-            let new_post = DiscussionPost {
-                edition_number: post.edition_number + 1,
-                ..post
-            };
 
             // mutation
 
-            <PostThreadIdByPostId<T>>::insert(thread_id, post_id, new_post);
             Self::deposit_event(RawEvent::PostUpdated(post_id, post_author_id));
        }
 

+ 0 - 2
runtime-modules/proposals/discussion/src/tests/mock.rs

@@ -30,7 +30,6 @@ parameter_types! {
 }
 
 parameter_types! {
-    pub const MaxPostEditionNumber: u32 = 5;
     pub const MaxThreadInARowNumber: u32 = 3;
     pub const ThreadTitleLengthLimit: u32 = 200;
     pub const PostLengthLimit: u32 = 2000;
@@ -86,7 +85,6 @@ impl crate::Trait for Test {
     type CouncilOriginValidator = CouncilMock;
     type ThreadId = u64;
     type PostId = u64;
-    type MaxPostEditionNumber = MaxPostEditionNumber;
     type MaxThreadInARowNumber = MaxThreadInARowNumber;
     type MaxWhiteListSize = MaxWhiteListSize;
 }

+ 1 - 25
runtime-modules/proposals/discussion/src/tests/mod.rs

@@ -49,10 +49,7 @@ fn assert_thread_content(thread_entry: TestThreadEntry, post_entries: Vec<TestPo
     for post_entry in post_entries {
         let actual_post =
             <PostThreadIdByPostId<Test>>::get(thread_entry.thread_id, post_entry.post_id);
-        let expected_post = DiscussionPost {
-            author_id: 1,
-            edition_number: post_entry.edition_number,
-        };
+        let expected_post = DiscussionPost { author_id: 1 };
 
         assert_eq!(actual_post, expected_post);
     }
@@ -257,27 +254,6 @@ fn update_post_call_succeeds() {
     });
 }
 
-#[test]
-fn update_post_call_fails_because_of_post_edition_limit() {
-    initial_test_ext().execute_with(|| {
-        let discussion_fixture = DiscussionFixture::default();
-
-        let thread_id = discussion_fixture
-            .create_discussion_and_assert(Ok(1))
-            .unwrap();
-
-        let mut post_fixture = PostFixture::default_for_thread(thread_id);
-
-        post_fixture.add_post_and_assert(Ok(()));
-
-        for _ in 1..6 {
-            post_fixture.update_post_and_assert(Ok(()));
-        }
-
-        post_fixture.update_post_and_assert(Err(Error::<Test>::PostEditionNumberExceeded.into()));
-    });
-}
-
 #[test]
 fn update_post_call_fails_because_of_the_wrong_author() {
     initial_test_ext().execute_with(|| {

+ 0 - 3
runtime-modules/proposals/discussion/src/types.rs

@@ -25,9 +25,6 @@ pub struct DiscussionThread<ThreadAuthorId, BlockNumber, MemberId> {
 pub struct DiscussionPost<PostAuthorId> {
     /// Author of the post.
     pub author_id: PostAuthorId,
-
-    /// Defines how many times this post was edited. Zero on creation.
-    pub edition_number: u32,
 }
 
 /// Post for the discussion thread

+ 0 - 2
runtime/src/lib.rs

@@ -577,7 +577,6 @@ impl Default for Call {
 }
 
 parameter_types! {
-    pub const ProposalMaxPostEditionNumber: u32 = 0; // post update is disabled
     pub const ProposalMaxThreadInARowNumber: u32 = 100_000; // will not be used
     pub const MaxWhiteListSize: u32 = 20;
 }
@@ -588,7 +587,6 @@ impl proposals_discussion::Trait for Runtime {
     type CouncilOriginValidator = CouncilManager<Self>;
     type ThreadId = ThreadId;
     type PostId = PostId;
-    type MaxPostEditionNumber = ProposalMaxPostEditionNumber;
     type MaxThreadInARowNumber = ProposalMaxThreadInARowNumber;
     type MaxWhiteListSize = MaxWhiteListSize;
 }