Browse Source

Add forum bureacracy record to the construct_runtime!

- add forum bureacracy record to the construct_runtime!
- rename ensure_is_forum_sudo() to ensure_is_forum_lead()
Shamil Gadelshin 4 years ago
parent
commit
dfbe36cb25
3 changed files with 14 additions and 17 deletions
  1. 4 8
      runtime-modules/bureaucracy/src/lib.rs
  2. 9 9
      runtime-modules/forum/src/lib.rs
  3. 1 0
      runtime/src/lib.rs

+ 4 - 8
runtime-modules/bureaucracy/src/lib.rs

@@ -3,7 +3,7 @@
 
 mod types;
 
-use srml_support::{decl_module, decl_event, decl_storage, dispatch};
+use srml_support::{decl_event, decl_module, decl_storage, dispatch};
 use system::ensure_root;
 
 use types::Lead;
@@ -15,15 +15,11 @@ pub static MSG_CURRENT_LEAD_ALREADY_SET: &str = "Current lead is already set";
 pub static MSG_IS_NOT_LEAD_ACCOUNT: &str = "Not a lead account";
 
 /// Alias for the _Lead_ type
-pub type LeadOf<T> = Lead<
-    <T as membership::members::Trait>::MemberId,
-    <T as system::Trait>::AccountId,
->;
+pub type LeadOf<T> =
+    Lead<<T as membership::members::Trait>::MemberId, <T as system::Trait>::AccountId>;
 
 /// The bureaucracy main _Trait_
-pub trait Trait<I: Instance>:
-    system::Trait + membership::members::Trait
-{
+pub trait Trait<I: Instance>: system::Trait + membership::members::Trait {
     /// Bureaucracy event type.
     type Event: From<Event<Self, I>> + Into<<Self as system::Trait>::Event>;
 }

+ 9 - 9
runtime-modules/forum/src/lib.rs

@@ -412,8 +412,8 @@ decl_module! {
             // Check that its a valid signature
             let who = ensure_signed(origin)?;
 
-            // Not signed by forum SUDO
-            Self::ensure_is_forum_sudo(&who)?;
+            // Not signed by forum lead
+            Self::ensure_is_forum_lead(&who)?;
 
             // Validate title
             Self::ensure_category_title_is_valid(&title)?;
@@ -491,8 +491,8 @@ decl_module! {
             // Check that its a valid signature
             let who = ensure_signed(origin)?;
 
-            // Not signed by forum SUDO
-            Self::ensure_is_forum_sudo(&who)?;
+            // Not signed by forum lead
+            Self::ensure_is_forum_lead(&who)?;
 
             // Make sure something is actually being changed
             ensure!(
@@ -597,8 +597,8 @@ decl_module! {
             // Check that its a valid signature
             let who = ensure_signed(origin)?;
 
-            // Signed by forum SUDO
-            Self::ensure_is_forum_sudo(&who)?;
+            // Signed by forum lead
+            Self::ensure_is_forum_lead(&who)?;
 
             // Get thread
             let mut thread = Self::ensure_thread_exists(thread_id)?;
@@ -732,8 +732,8 @@ decl_module! {
             // Check that its a valid signature
             let who = ensure_signed(origin)?;
 
-            // Signed by forum SUDO
-            Self::ensure_is_forum_sudo(&who)?;
+            // Signed by forum lead
+            Self::ensure_is_forum_lead(&who)?;
 
             // Make sure post exists and is mutable
             let post = Self::ensure_post_is_mutable(post_id)?;
@@ -876,7 +876,7 @@ impl<T: Trait> Module<T> {
         }
     }
 
-    fn ensure_is_forum_sudo(account_id: &T::AccountId) -> dispatch::Result {
+    fn ensure_is_forum_lead(account_id: &T::AccountId) -> dispatch::Result {
         bureaucracy::Module::<T, bureaucracy::Instance1>::ensure_is_lead_account(account_id.clone())
     }
 

+ 1 - 0
runtime/src/lib.rs

@@ -917,6 +917,7 @@ construct_runtime!(
         ProposalsDiscussion: proposals_discussion::{Module, Call, Storage, Event<T>},
         ProposalsCodex: proposals_codex::{Module, Call, Storage, Error, Config<T>},
         // ---
+        ForumBureaucracy: bureaucracy::<Instance1>::{Module, Call, Storage, Event<T>},
     }
 );