tBKwtWS hace 6 años
padre
commit
28e9068ab8

+ 18 - 0
website/rotbot/migrations/0002_user_xp_corrention.py

@@ -0,0 +1,18 @@
+# Generated by Django 2.2.6 on 2019-11-17 21:29
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('rotbot', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='user',
+            name='xp_corrention',
+            field=models.PositiveIntegerField(default=0),
+        ),
+    ]

+ 3 - 6
website/rotbot/models.py

@@ -265,16 +265,10 @@ class User(models.Model):
         on_delete=models.CASCADE,
         null=True,
     )
-    last_event_user = models.ForeignKey(
-        'User',
-        on_delete=models.CASCADE,
-        null=True,
-    )
     last_event_subject = models.ForeignKey(
         'User',
         on_delete=models.CASCADE,
         null=True,
-        related_name='user_subject',
     )
     last_event_content = models.CharField(
         null=True,
@@ -301,6 +295,9 @@ class User(models.Model):
     karma_correction = models.PositiveIntegerField(
         default=0,
     )
+    xp_corrention = models.PositiveIntegerField(
+        default=0,
+    )
     no_chat = models.BooleanField(
         default=False,
     )

+ 84 - 9
website/rotbot/templates/rotbot/network.html

@@ -3,7 +3,8 @@
   <div class="ui three inverted grey statistics">
     <div class="statistic">
       <div class="value">
-        <i class="server icon"></i> {{ total_hosts }}
+        <i class="server icon"></i>
+        {{ total_hosts }}
       </div>
       <div class="label">
         Hosts
@@ -11,7 +12,8 @@
     </div>
     <div class="statistic">
       <div class="value">
-        <i class="hashtag icon"></i> {{ total_chanels }}
+        <i class="hashtag icon"></i>
+        {{ total_chanels }}
       </div>
       <div class="label">
         Channels
@@ -19,7 +21,8 @@
     </div>
     <div class="statistic">
       <div class="value">
-        <i class="users icon"></i> {{ total_users }}
+        <i class="users icon"></i>
+        {{ total_users }}
       </div>
       <div class="label">
         Users
@@ -29,7 +32,8 @@
   <div class="ui five tiny inverted grey statistics">
     <div class="statistic">
       <div class="value">
-        <i class="comments icon"></i> {{ total_messages }}
+        <i class="comments icon"></i>
+        {{ total_messages }}
       </div>
       <div class="label">
         Messages
@@ -37,7 +41,8 @@
     </div>
     <div class="statistic">
       <div class="value">
-        <i class="theater masks icon"></i> {{ total_actions }}
+        <i class="theater masks icon"></i>
+        {{ total_actions }}
       </div>
       <div class="label">
         Actions
@@ -45,7 +50,8 @@
     </div>
     <div class="statistic">
       <div class="value">
-        <i class="bullhorn icon"></i> {{ total_notices }}
+        <i class="bullhorn icon"></i>
+        {{ total_notices }}
       </div>
       <div class="label">
         Notices
@@ -53,7 +59,8 @@
     </div>
     <div class="statistic">
       <div class="value">
-        <i class="user plus icon"></i> {{ total_joins }}
+        <i class="user plus icon"></i>
+        {{ total_joins }}
       </div>
       <div class="label">
         Joins
@@ -61,14 +68,82 @@
     </div>
     <div class="statistic">
       <div class="value">
-        <i class="user slash icon"></i> {{ total_kicks }}
+        <i class="user slash icon"></i>
+        {{ total_kicks }}
       </div>
       <div class="label">
         Kicks
       </div>
     </div>
   </div>
-
+  <div class="ui six tiny inverted grey statistics">
+    <div class="statistic">
+      <div class="value">
+        <i class="thermometer half alternate icon"></i>
+        {{ total_level }}
+      </div>
+      <div class="label">
+        Level
+      </div>
+    </div>
+    <div class="statistic">
+      <div class="value">
+        <i class="icons">
+          <i class="tachometer alternate icon"></i>
+          <i class="inverted seedling corner icon"></i>
+        </i>
+        {{ total_xp_spent }}
+      </div>
+      <div class="label">
+        XP spent
+      </div>
+    </div>
+    <div class="statistic">
+      <div class="value">
+        <i class="icons">
+          <i class="gas pump icon"></i>
+          <i class="inverted seedling corner icon"></i>
+        </i>
+        {{ total_ap_spent }}
+      </div>
+      <div class="label">
+        AP spent
+      </div>
+    </div>
+    <div class="statistic">
+      <div class="value">
+        <i class="coins icon"></i>
+        {{ total_coin }}
+      </div>
+      <div class="label">
+        Coin
+      </div>
+    </div>
+    <div class="statistic">
+      <div class="value">
+        <i class="icons">
+          <i class="coins icon"></i>
+          <i class="inverted corner shopping cart icon"></i>
+        </i>
+        {{ total_coin_spent }}
+      </div>
+      <div class="label">
+        Coin spent
+      </div>
+    </div>
+    <div class="statistic">
+      <div class="value">
+        <i class="icons">
+          <i class="coins icon"></i>
+          <i class="inverted corner gift icon"></i>
+        </i>
+        {{ total_coin_given }}
+      </div>
+      <div class="label">
+        Coin given
+      </div>
+    </div>
+  </div>
 
   <div class="ui inverted card">
     <div class="content">

+ 69 - 0
website/rotbot/templates/rotbot/networks.html

@@ -76,6 +76,75 @@
       </div>
     </div>
   </div>
+  <div class="ui six tiny inverted grey statistics">
+    <div class="statistic">
+      <div class="value">
+        <i class="thermometer half alternate icon"></i>
+        {{ total_level }}
+      </div>
+      <div class="label">
+        Level
+      </div>
+    </div>
+    <div class="statistic">
+      <div class="value">
+        <i class="icons">
+          <i class="tachometer alternate icon"></i>
+          <i class="inverted seedling corner icon"></i>
+        </i>
+        {{ total_xp_spent }}
+      </div>
+      <div class="label">
+        XP spent
+      </div>
+    </div>
+    <div class="statistic">
+      <div class="value">
+        <i class="icons">
+          <i class="gas pump icon"></i>
+          <i class="inverted seedling corner icon"></i>
+        </i>
+        {{ total_ap_spent }}
+      </div>
+      <div class="label">
+        AP spent
+      </div>
+    </div>
+    <div class="statistic">
+      <div class="value">
+        <i class="coins icon"></i>
+        {{ total_coin }}
+      </div>
+      <div class="label">
+        Coin
+      </div>
+    </div>
+    <div class="statistic">
+      <div class="value">
+        <i class="icons">
+          <i class="coins icon"></i>
+          <i class="inverted corner shopping cart icon"></i>
+        </i>
+        {{ total_coin_spent }}
+      </div>
+      <div class="label">
+        Coin spent
+      </div>
+    </div>
+    <div class="statistic">
+      <div class="value">
+        <i class="icons">
+          <i class="coins icon"></i>
+          <i class="inverted corner gift icon"></i>
+        </i>
+        {{ total_coin_given }}
+      </div>
+      <div class="label">
+        Coin given
+      </div>
+    </div>
+  </div>
+
   {% if perms.rotbot.add_network %}
     <a href="{% url 'rotbot:add_network' %}" class="ui inverted right floated button">Add</a>
   {% endif %}

+ 144 - 9
website/rotbot/templates/rotbot/user.html

@@ -1,9 +1,10 @@
 {% extends "base.html" %}
 {% block content %}
-  <div class="ui three inverted grey statistics">
+  <div class="ui six small inverted grey statistics">
     <div class="statistic">
       <div class="value">
-        <i class="comment icon"></i> {{ total_messages }}
+        <i class="comment icon"></i>
+        {{ total_messages }}
       </div>
       <div class="label">
         messages
@@ -11,7 +12,8 @@
     </div>
     <div class="statistic">
       <div class="value">
-        <i class="theater masks icon"></i> {{ total_actions }}
+        <i class="theater masks icon"></i>
+        {{ total_actions }}
       </div>
       <div class="label">
         Actions
@@ -19,17 +21,17 @@
     </div>
     <div class="statistic">
       <div class="value">
-        <i class="bullhorn icon"></i> {{ total_notices }}
+        <i class="bullhorn icon"></i>
+        {{ total_notices }}
       </div>
       <div class="label">
         Notces
       </div>
     </div>
-  </div>
-  <div class="ui three tiny inverted grey statistics">
     <div class="statistic">
       <div class="value">
-        <i class="user plus icon"></i> {{ total_joins }}
+        <i class="user plus icon"></i>
+        {{ total_joins }}
       </div>
       <div class="label">
         Joins
@@ -37,7 +39,8 @@
     </div>
     <div class="statistic">
       <div class="value">
-        <i class="jet fighter icon"></i> {{ total_kicks }}
+        <i class="jet fighter icon"></i>
+        {{ total_kicks }}
       </div>
       <div class="label">
         Kicks
@@ -45,11 +48,143 @@
     </div>
     <div class="statistic">
       <div class="value">
-        <i class="user slash icon"></i> {{ total_kicked }}
+        <i class="user slash icon"></i>
+        {{ total_kicked }}
       </div>
       <div class="label">
         Kicked
       </div>
     </div>
   </div>
+  <div class="ui six tiny inverted grey statistics">
+    <div class="statistic">
+      <div class="value">
+        <i class="thermometer half alternate icon"></i>
+        {{ user.level }}
+      </div>
+      <div class="label">
+        Level
+      </div>
+    </div>
+    <div class="statistic">
+      <div class="value">
+        <i class="icons">
+          <i class="tachometer alternate icon"></i>
+          <i class="inverted seedling corner icon"></i>
+        </i>
+        {{ user.xp_spent }}
+      </div>
+      <div class="label">
+        XP spent
+      </div>
+    </div>
+    <div class="statistic">
+      <div class="value">
+        <i class="icons">
+          <i class="gas pump icon"></i>
+          <i class="inverted seedling corner icon"></i>
+        </i>
+        {{ user.ap_spent }}
+      </div>
+      <div class="label">
+        AP spent
+      </div>
+    </div>
+    <div class="statistic">
+      <div class="value">
+        <i class="coins icon"></i>{{ user.coin }}
+      </div>
+      <div class="label">
+        Coin
+      </div>
+    </div>
+    <div class="statistic">
+      <div class="value">
+        <i class="icons">
+          <i class="coins icon"></i>
+          <i class="inverted corner shopping cart icon"></i>
+        </i>
+        {{ user.coin_spent }}
+      </div>
+      <div class="label">
+        Coin spent
+      </div>
+    </div>
+    <div class="statistic">
+      <div class="value">
+        <i class="icons">
+          <i class="coins icon"></i>
+          <i class="inverted corner gift icon"></i>
+        </i>
+        {{ user.coin_given }}
+      </div>
+      <div class="label">
+        Coin given
+      </div>
+    </div>
+  </div>
+
+  <i class="history icon"></i>Last seen {{ last_event_type }}
+  {% if user.last_event_subject %}
+    <i class="icons"><i class="heading icon"></i><i class="corner history icon"></i></i>{{ user.last_event_subject }}
+  {% endif %}
+  {% if user.last_event_channel %}
+    in <i class="icons"><i class="hashtag icon"></i><i class="corner history icon"></i></i>{{ user.last_event_channel }}
+  {% endif %}
+  {% if user.last_event_content %}
+    for <i class="icons"><i class="envelope icon"></i><i class="corner history icon"></i></i>{{ user.last_event_content }}
+  {% endif %}
+  at {{ user.last_event_datetime }}
+
+  <i class="microphone alternate slash icon"></i>{{ user.no_chat }}
+
+<canvas id="myChart"></canvas>
+<script>
+  var ctx = document.getElementById('myChart').getContext('2d');
+  var myChart = new Chart(ctx, {
+  type: 'radar',
+  data: {
+    labels: ['Messages', 'Actions', 'Notices', 'Joins', 'Kicks', 'Kicked'],
+    datasets: [{
+      label: 'Statistics per channel',
+      data: [{{ total_messages }}, {{ total_actions }}, {{ total_notices }}, {{ total_joins }}, {{ total_kicks }}, {{ total_kicked }}],
+      backgroundColor: [
+        'rgba(255, 99, 132, 0.2)',
+        'rgba(54, 162, 235, 0.2)',
+        'rgba(255, 206, 86, 0.2)',
+        'rgba(75, 192, 192, 0.2)',
+        'rgba(153, 102, 255, 0.2)',
+        'rgba(255, 159, 64, 0.2)'
+      ],
+      borderColor: [
+        'rgba(255, 99, 132, 1)',
+        'rgba(54, 162, 235, 1)',
+        'rgba(255, 206, 86, 1)',
+        'rgba(75, 192, 192, 1)',
+        'rgba(153, 102, 255, 1)',
+        'rgba(255, 159, 64, 1)'
+      ],
+      borderWidth: 1
+    }]
+  },
+  options: {
+    pointLabels: {
+      display: false,
+    },
+    legend: {
+      display: true,
+      labels: {
+        fontColor: 'rgb(255, 99, 132)'
+      }
+    },
+    scales: {
+      yAxes: [{
+        ticks: {
+          beginAtZero: true
+        }
+      }]
+    }
+    }
+  });
+</script>
 {% endblock content %}

+ 35 - 0
website/rotbot/views/general.py

@@ -49,6 +49,39 @@ def user(request, user_slug):
     kicks = Kick.objects.filter(kicker=user)
     kicked = Kick.objects.filter(kicked=user)
 
+    if user.last_event_type == 'pm':
+        last_event_type = 'speaking privately'
+    if user.last_event_type == 'pa':
+        last_event_type = 'sending a private action'
+    if user.last_event_type == 'pn':
+        last_event_type = 'sending a private notice'
+    if user.last_event_type == 'cm':
+        last_event_type = 'speaking publicly'
+    if user.last_event_type == 'ca':
+        last_event_type = 'sending a public action'
+    if user.last_event_type == 'cn':
+        last_event_type = 'sending a public notice'
+    if user.last_event_type == 'ct':
+        last_event_type = 'changing the topic'
+    if user.last_event_type == 'ck':
+        last_event_type = 'changing the password'
+    if user.last_event_type == 'ci':
+        last_event_type = 'inviting'
+    if user.last_event_type == 'cj':
+        last_event_type = 'joining'
+    if user.last_event_type == 'cp':
+        last_event_type == 'parting'
+    if user.last_event_type == 'ck':
+        last_event_type = 'kicking'
+    if user.last_event_type == 'kd':
+        last_event_type = 'getting kicked'
+    if user.last_event_type == 'mc':
+        last_event_type = 'changing modes'
+    if user.last_event_type == 'nc':
+        last_event_type = 'nick change'
+    if user.last_event_type =='sq':
+        last_event_type = 'quitting'
+
     context = {
         'parent_title': network.name,
         'parent_url': reverse('rotbot:network', args=(network.slug,)),
@@ -65,9 +98,11 @@ def user(request, user_slug):
         'total_joins': shorten_number(joins.count()),
         'total_kicks': shorten_number(kicked.count()),
         'total_kicked': shorten_number(kicked.count()),
+        'last_event_type': last_event_type,
     }
     return render(request, 'rotbot/user.html', context)
 
+
 @login_required
 @permission_required('rotbot.add_curseword', raise_exception=True)
 def add_curseword(request):

+ 29 - 0
website/rotbot/views/network.py

@@ -18,6 +18,7 @@ def networks(request):
     notices = Notice.objects.all()
     joins = Join.objects.all()
     kicks = Kick.objects.all()
+    total_level, total_xp_spent, total_ap_spent, total_coin, total_coin_spent, total_coin_given = user_totals(users)
 
     context = {
         'title': 'RotBot',
@@ -34,9 +35,30 @@ def networks(request):
         'total_notices': shorten_number(total_messages(notices)),
         'total_joins': shorten_number(joins.count()),
         'total_kicks': shorten_number(kicks.count()),
+        'total_level': total_level,
+        'total_xp_spent': total_xp_spent,
+        'total_ap_spent': total_ap_spent,
+        'total_coin': total_coin,
+        'total_coin_spent': total_coin_spent,
+        'total_coin_given': total_coin_given,
     }
     return render(request, 'rotbot/networks.html', context)
 
+def user_totals(users):
+    total_level = 0
+    total_xp_spent = 0
+    total_ap_spent = 0
+    total_coin = 0
+    total_coin_spent = 0
+    total_coin_given = 0
+    for user in users:
+        total_level += user.level
+        total_xp_spent += user.xp_spent
+        total_ap_spent += user.ap_spent
+        total_coin += user.coin
+        total_coin_spent += user.coin_spent
+        total_coin_given += user.coin_given
+    return total_level, total_xp_spent, total_ap_spent, total_coin, total_coin_spent, total_coin_given
 
 def network(request, network_slug):
     network = get_object_or_404(Network, slug=network_slug)
@@ -51,6 +73,7 @@ def network(request, network_slug):
 
     for host in hosts:
         host.connection_fails = host.connection_attempts - host.connection_succeeds
+    total_level, total_xp_spent, total_ap_spent, total_coin, total_coin_spent, total_coin_given = user_totals(users)
 
     context = {
         'parent_title': 'Networks',
@@ -71,6 +94,12 @@ def network(request, network_slug):
         'total_notices': shorten_number(total_messages(notices)),
         'total_joins': shorten_number(joins.count()),
         'total_kicks': shorten_number(kicks.count()),
+        'total_level': total_level,
+        'total_xp_spent': total_xp_spent,
+        'total_ap_spent': total_ap_spent,
+        'total_coin': total_coin,
+        'total_coin_spent': total_coin_spent,
+        'total_coin_given': total_coin_given,
     }
     return render(request, 'rotbot/network.html', context)
 

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 6 - 0
website/static/Chart.min.js


+ 1 - 1
website/templates/base.html

@@ -19,7 +19,7 @@
     <script src="{% static "jquery@3.3.1/dist/jquery.min.js" %}"></script>
     <link rel="stylesheet" type="text/css" href="{% static "semantic.min.css" %}">
     <script src="{% static "semantic.min.js" %}"></script>
-    {% block head %}{% endblock head %}
+    <script src="{% static "Chart.min.js" %}"></script>
   </head>
   <body>
     <nav class="ui pointing top fixed inverted menu">

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio